get_look_yaw

User avatar
Echo
Member
 
Posts: 121
Joined: Tue Jul 31, 2012 08:11

get_look_yaw

by Echo » Tue Sep 04, 2012 21:30

Found a difference between the function get_look_yaw and the output when pressing F5
If I'm not wrong you convert from radians to degrees this way:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local degree = player:get_look_yaw()*180/math.pi

This results in values 90° shifted to the debug-output.

So your next attempt will be:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local degree = player:get_look_yaw()*180/math.pi - 90

That results often in correct values. But sometimes in negative values, no not just by the 90°. They are really absurd.

Next try:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local degree = player:get_look_yaw()*180/math.pi - 90
if degree < 0 then degree = degree + 360 end


Aw, c'mon. You really have to do this?
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Wed Sep 05, 2012 15:28

If you add the if statement you can delete the -90.
 

wokste
Member
 
Posts: 78
Joined: Sat Feb 11, 2012 09:06

by wokste » Fri Sep 07, 2012 11:21

I think the best way to fix this is to correct the F5 to be the same as player:get_look_yaw(). In this way, potential existing mods will be backward compatible.
EDIT: Of course in radians, but the same 0 axis (I hope it is clear)
Last edited by wokste on Fri Sep 07, 2012 11:21, edited 1 time in total.
We must be careful not to clone Notches mistakes.
 

User avatar
AndrOn
Member
 
Posts: 38
Joined: Fri May 31, 2013 22:32

by AndrOn » Mon Jul 08, 2013 23:13

I'm having trouble with this function: when I do this:

(p is a player)

local yaw = p:get_look_yaw()*180/math.pi
p:set_look_yaw(yaw*math.pi/180)

it actually shakes the camera around, it's really weird.

(same thing when I modify pitch)

[edit] corrected an illogical variable name
Last edited by AndrOn on Tue Jul 09, 2013 08:22, edited 1 time in total.
sorry for bad english
 

User avatar
AndrOn
Member
 
Posts: 38
Joined: Fri May 31, 2013 22:32

by AndrOn » Mon Jul 15, 2013 17:16

ok, solved the problem:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
(p is a player)

            local yaw = p:get_look_yaw()*180/math.pi           
            p:set_look_yaw(yaw)


still 2 things: This code locks the camera and it's buggy, and it's not very logical that get_look_yaw gives the yaw in radians and that set_look_yaw takes it in degrees..
sorry for bad english
 

User avatar
RealBadAngel
Member
 
Posts: 556
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Sun Jul 21, 2013 13:51

AndrOn wrote:ok, solved the problem:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
(p is a player)

            local yaw = p:get_look_yaw()*180/math.pi           
            p:set_look_yaw(yaw)


still 2 things: This code locks the camera and it's buggy, and it's not very logical that get_look_yaw gives the yaw in radians and that set_look_yaw takes it in degrees..



Huh? set_look_yaw definitely need radians value, example use:

dest_angle = 90
player:set_look_yaw(math.rad(dest_angle))
 


Return to Minetest Problems

Who is online

Users browsing this forum: No registered users and 6 guests

cron