Page 1 of 1

[Question] getyaw()

PostPosted: Thu Jul 11, 2019 02:21
by Extex
I'm pretty sure player:getyaw() has been removed.
So what is the new method?
I tried
Code: Select all
player:get_look_yaw()

But as I rotate I just get weird values in order like this:
Code: Select all
7, 6, 5, 4, 3, 2, 1, 7 ect


And
Code: Select all
player:get_look_dir().x

I get values like this:
Code: Select all
0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0 then does the same thing but with negative values then comes back

What do I do to get the proper 360 or -180 to 180 player yaw?
If not how to I convert 1-7 into 360 rotation?

Re: [Question] getyaw()

PostPosted: Thu Jul 11, 2019 04:38
by v-rob
get_look_yaw is deprecated because it's broken. Use get_look_horizontal instead. The same is true for get_look_pitch, so use get_look_vertical for that.

Note that get_look_horizontal and get_look_vertical return in radians, so to get degrees, use math.deg like so:

Code: Select all
local yaw = math.deg(player:get_look_horizontal())


And if you need to set the value, use math.rad:

Code: Select all
player:set_look_horizontal(math.rad(96))

Re: [Question] getyaw()

PostPosted: Thu Jul 11, 2019 18:51
by Krock
Here are some images to explain stuff: https://dev.minetest.net/Player

Re: [Question] getyaw()

PostPosted: Fri Jul 12, 2019 00:44
by Extex
Thanks so much it work worked