[英]How do I make an object move in the direction that it's facing in ursina?
I want to be able to make an object move forward in ursina, but can't figure out how.我希望能够在 ursina 中进行 object 前进,但不知道如何做。
I tried the.forward method but that only gives the direction and I don't know where to go from there.我尝试了 .forward 方法,但它只给出了方向,我不知道从那里到 go 的位置。
Do entity.position += entity.forward
to move it forward, while taking rotation into account.执行entity.position += entity.forward
使其向前移动,同时考虑旋转。 If you don't need to account for rotation, entity.z += 1
would work too.如果您不需要考虑旋转, entity.z += 1
也可以。
Example where we move forward while the w key is pressed:按下 w 键时我们向前移动的示例:
from ursina import *
app = Ursina()
entity = Entity(model='cube')
def update():
entity.position += entity.forward * time.dt * held_keys['w']
app.run()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.