[Question] getyaw()

Extex
Member
 
Posts: 113
Joined: Wed Mar 14, 2018 23:14
GitHub: Extex101
In-game: Extex

[Question] getyaw()

by Extex » Thu Jul 11, 2019 02:21

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?
Player of PK, RIP. Creator of the light_tool mod. Working on another mod which is pretty cool so far
 

User avatar
v-rob
Member
 
Posts: 685
Joined: Thu Mar 24, 2016 03:19
Location: Right behind you.
GitHub: v-rob

Re: [Question] getyaw()

by v-rob » Thu Jul 11, 2019 04:38

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))
 

User avatar
Krock
Developer
 
Posts: 4393
Joined: Thu Oct 03, 2013 07:48
Location: Switzerland
GitHub: SmallJoker

Re: [Question] getyaw()

by Krock » Thu Jul 11, 2019 18:51

Here are some images to explain stuff: https://dev.minetest.net/Player
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
 

Extex
Member
 
Posts: 113
Joined: Wed Mar 14, 2018 23:14
GitHub: Extex101
In-game: Extex

Re: [Question] getyaw()

by Extex » Fri Jul 12, 2019 00:44

Thanks so much it work worked
Player of PK, RIP. Creator of the light_tool mod. Working on another mod which is pretty cool so far
 


Return to Modding Discussion



Who is online

Users browsing this forum: cronvel, Majestic-12 [Bot] and 4 guests