admin管理员组文章数量:1123788
I'm making a simple space simulator, and all I need is to fly around. I managed to make camera move around but I cannot make it rotate correctly along its axes. I couldn't make FirstPersonController fly, so I decided to make my own camera.
This is the movement in xyz:
direction = Vec3(camera.forward * (held_keys['w'] - held_keys['s']) + camera.right * (held_keys['d'] - held_keys['a']) + camera.up * (held_keys['e'] - held_keys['q'])).normalized()
camera.position += direction * speed * time.dt
Rotation along 1 axis works well:
camera.rotation_y += mouse.velocity[0] * sensitivity
When I add rotation_x, it's a mess. It rotates along world X axis no matter the direction. The same with z axis.
I tried to add camera_pivot entity and rotate it along one axis and camera itself along another axis, but it still doesn't work properly:
camera_pivot = Entity()
camera.parent = camera_pivot
camera.position = (0, 0, 0)
camera.rotation = (0, 0, 0)
update section:
camera_pivot.rotation_x -= mouse.velocity[1] * sensitivity
camera.rotation_y += mouse.velocity[0] * sensitivity
Upd: EditorCamera has the same problem. If you look up, then you can't look right/left, the view is rotating in front of you.
本文标签: pythonHow do I rotate camera in Ursina engineStack Overflow
版权声明:本文标题:python - How do I rotate camera in Ursina engine? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736596169a1945152.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论