- Home /
How to move character Forward on It's own Axis, and not the World Axis?
I used this for a character and then i used it for another character too. They were both facing opposite directions and it was funny. one of them walked forward,and one of them walked backwards.
So i know that it's probably because they're walking using the World axis and not their own.
This is what i used and i attached the script to both characters:
void Update () { transform.position += new Vector3( 0, 0, 0.1f); }
I'm guessing this is the wrong thing to use.
**By the way. I just have the character with a Rigid body. It's not a Character Controller.
*UPDATE. I was looking around in the web and I found transform.Translate(0, 0, 0.02f, Space.Self )
I used it and it kinda works. But the character for some reason starts changing rotation gradually while walking. So i guess maybe this is not a good method to use?
Answer by DFLY · Aug 31, 2013 at 04:58 AM
// Move translation along the object's z-axis
transform.Translate (Vector3.forward * (speed) * Time.deltaTime);
// speed will be a float variable.
I'm a noob, so excuse me. I noticed that the object moves "forward" depending on where it is facing (most likely because of Vector3.forward). But how do you make it move forward on an x/y/z axis regardless of where it is facing?
// $$anonymous$$ove the object upward in world space 1 unit/second.
transform.Translate(Vector3.up * Time.deltaTime, Space.World);
I copied this straight out of the manual. Look up "Transform.Translate" in the manual. It gives a full description. But basically you add the space reference to the end. (in this case "Space.World").
Your answer
![](https://koobas.hobune.stream/wayback/20220613113319im_/https://answers.unity.com/themes/thub/images/avi.jpg)