Error when make the objects both MoveLeft and Spinning in Unity

kdfashioninc 注册会员
2023-01-25 06:34

Both Translate and Rotate per default work in of according object unless you explicitly pass in Space.World as additional last parameter.

So, after rotating your object around the Y-axis it's local left vector is now rotated as well and pointing somewhere else.

=> When you do the translation towards left of the object it doesn't actually move left in the world.

In order to move left in absolute world space you want to use

transform.Translate(Vector3.left * Time.deltaTime * moveLeftSpeed, Space.World);