简体   繁体   中英

How do I find the x and z rotation of the firstpersoncontroller in Ursina?

I need to find out the players rotation angles in a demo game I am making. Problem is, when I do this:

print(player.rotation_x, player.rotation_y, player.rotation_z)

It only shows rotation_y, and not the other two.

I then tried the same thing with camera.rotation_x:

print(camera.rotation_x, camera.rotation_y, camera.rotation_z)

which would normally work but because I am using FirstPersonController just returns

0.0, 0.0, 0.0

Is there anyway I can find out the rotation angle of the FirstPersonController?

Okay so I found out the answer by checking the source code of Ursina Engine.

Basically, the FirstPersonController works by using

self.camera_pivot

so instead of using

player.rotation_x, player.rotation_y, player.rotation_z

you have to use

player.camera_pivot.rotation_x, player.camera_pivot.rotation_y, player.camera_pivot.rotation_z

the only exception to this is

player.rotation_y

which will still work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM