如何让精灵在2D空间中向下移动?

时间:2020-12-25 18:18:56

I am trying to make a game object in unity just go vertically down.

我试图将一个游戏对象统一起来,然后垂直向下。

I have tried using GameObject.transform() and things like that. All I am asking is, if anyone can give me something to look into such as which method or class I would use to make a 2D sprite move downward.

我尝试过使用GameObject.transform()等类似的东西。我要问的是,如果有人可以给我一些东西来研究,比如我将使用哪种方法或类来使2D精灵向下移动。

1 个解决方案

#1


In Unity, you can modify the position of any object using it's transform component and it's position property. For example, if you have GameObject someSprite, you can assign a new value to someSprite.transform.position every frame. Usually it is done in your Update method, or, if you're working with physics, in the FixedUpdate method.

在Unity中,您可以使用它的变换组件及其位置属性来修改任何对象的位置。例如,如果您有GameObject someSprite,则可以为每个帧的someSprite.transform.position指定一个新值。通常它是在您的Update方法中完成的,或者,如果您正在使用物理,则在FixedUpdate方法中完成。

#1


In Unity, you can modify the position of any object using it's transform component and it's position property. For example, if you have GameObject someSprite, you can assign a new value to someSprite.transform.position every frame. Usually it is done in your Update method, or, if you're working with physics, in the FixedUpdate method.

在Unity中,您可以使用它的变换组件及其位置属性来修改任何对象的位置。例如,如果您有GameObject someSprite,则可以为每个帧的someSprite.transform.position指定一个新值。通常它是在您的Update方法中完成的,或者,如果您正在使用物理,则在FixedUpdate方法中完成。