Unity; Vector3.Forward, changes x position, not declared z position

264 views Asked by At

Can someone explain to me why when I declare "Vector3.Forward" or the equivalent "Vector3(0,0,1)" it changes the gameObject in the X-position rather than the Z position? It's really simple, but I'm lost for words. The third variable where the 1 is located is for the z-position, and not for the x-position. Right?

The code works, I'm just confused about the logic behind it.

1

There are 1 answers

0
Daahrien On

What do you mean by "it changes"? are you .Translate-ing it?

If you are, you're probably translating it in the Local Space. If you want to translate in the World Space, add the second parameter to .Translate like this:

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