[Question] getyaw()

Post Reply
User avatar
Extex
Member
Posts: 190
Joined: Wed Mar 14, 2018 23:14
GitHub: Extex101
In-game: Extex

[Question] getyaw()

by Extex » Post

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 and motorbike mods. Working on another mod which should be coming soon!

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

Re: [Question] getyaw()

by v-rob » Post

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))
GUI Core Developer | My Best Mods: Bridger - Slats - Stained Glass | To contact me, send a PM

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

Re: [Question] getyaw()

by Krock » Post

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>

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

Re: [Question] getyaw()

by Extex » Post

Thanks so much it work worked
Player of PK, RIP. Creator of the light_tool and motorbike mods. Working on another mod which should be coming soon!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests