Object doesn't moving well in rotation

448 views Asked by At

When my object is rotating, the object doesn't moving toward to the position I want it to be

Here's my code :

transform.Rotate (0,0, 3.0f);
transform.Translate(0, -movespeed * Time.deltaTime, 0); 
1

There are 1 answers

0
maraaaaaaaa On

Translate moves your object according to its own transform orientation, so you could probably do 1 of 3 things:

  1. Put the game object you want to rotate inside of another game object, then you can rotate it however which way you want and just translate the parent in the direction you want to go.

  2. Set the direction you want him to travel more explicitly... transform.Translate(SomeTransform.up * -movespeed * Time.deltaTime);

  3. Pass a "relativeTo" parameter... transform.Translate(new Vector3(0, -movespeed * Time.deltaTime, 0), Space.World);