简体   繁体   English

如何使 object 朝它在 ursina 中所面对的方向移动?

[英]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.

相关问题 pygame - 如何使精灵在向量的方向上移动? - pygame - How to make sprite move in the direction it's facing with vectors? 如何使用 Ursina 实现敌人碰撞并在 Ursina 中更改子弹方向? - How do I implement enemy collision using Ursina and change bullet direction in Ursina? 你如何让汽车朝着它所面对的方向移动? (使用 python 和海龟图形) - How do you make a car move in the direction it is facing? (Using python and turtle graphics) "Python Ursina 汽车移动方向" - Python Ursina car move direction 如何使用 Ursina Python 制作菜单屏幕? - How do I make a menu screen using Ursina Python? 如何通过一次按键在一个方向上移动对象,直到方向改变? - How do I move an object in one direction with a single keypress until the direction is changed? 如何让汽车移动它指向的方向(使用pygame.translation.rotate之后) - How would I make a car move the direction it's pointing (After use of pygame.translation.rotate) 我如何使用 Ursina 获取用户输入 - How do i get user input with Ursina 我如何在 Ursina 第一人称控制器中使用“a”和“d”键而不是鼠标旋转汽车 - how do i make a car in Ursina firstpersoncontroller rotate using the 'a' and 'd' keys, not the mouse Ursina / Python - 如何使 update() 从坐标而不是时间修改位置 - Ursina / Python - How do I make it so update() modifies positions from coordinates instead of time
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM