Page 1 of 1

get_look_yaw

PostPosted: Tue Sep 04, 2012 21:30
by Echo
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?

PostPosted: Wed Sep 05, 2012 15:28
by PilzAdam
If you add the if statement you can delete the -90.

PostPosted: Fri Sep 07, 2012 11:21
by wokste
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)

PostPosted: Mon Jul 08, 2013 23:13
by AndrOn
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

PostPosted: Mon Jul 15, 2013 17:16
by AndrOn
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..

PostPosted: Sun Jul 21, 2013 13:51
by RealBadAngel
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))