# Vector3.forward

My Game object rotates and then moves forward using Vector3.forward, the problem im having is that when it rotates its doesnt send the object in the foward direction that the rotated object is now facing…

``````var rotation = Quaternion.LookRotation(target);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 3);

transform.position += Vector3.forward * Time.deltaTime;
``````

That’s because Vector3.forward is shorthand for writing Vector3(0, 0, 1). So it will actually not he the direction you are facing once you have rotated.

so what can I do to make my object just carry on going foward in the direction its facing forever?

Try: transform.TransformDirection(Vector3.forward)

It says:

Look rotation viewing vector is zero, ive tested what transform.TransformDirection(Vector3.forward) value is and it is not zero… my object still doesnt move… any ideas?

Ohh, sorry. Let me clarify. The transform actually has to belong to some game object. As for my game that is 3rd person I use the camera.

``````Transform cameraTransform = Camera.main.transform;

// Forward vector relative to the camera along the x-z plane.
Vector3 vForwardVector = cameraTransform.TransformDirection(Vector3.forward);
``````

Edit: But then again the transform does belong to your current game object so that is kind of odd. Wasn’t thinking :). I am guessing your script is directly parented to the game object that you wish to move?

yeh its direct parenting and still no movement… any ideas?

transform.position += transform.TransformDirection(Vector3.forward) * Time.deltaTime;

Does nothing?
What values are you getting if you do:

Debug.Log(transform.TransformDirection(Vector3.forward).ToString() + " " + Time.deltaTime.ToString());

Can you use transform.forward instead of Vector3.forward?

Those two items do very different things. Sorry I haven’t read all the posts above so I’m not sure on context here…

Vector3.forward is the same as making a new vector with x,y,z values of 0,0,1.

Transform.forward gives you the transform’s z-axis in world space. If the transform isn’t rotated then that’s the same as Vector3.forward, otherwise it’s going to be something different.

tttttttttttttttttttt transform.forward in most cases.