Transform.forward or Vector3.forward?

In the lecture Rick uses Vector3.forward while showing and explaining it with transform.forward. I tried transform.forward and it does not work, it’s just shortform for the global z-axis. But shouldn’t Vector3.forward be the global z-axis as it does not know the rotation and therefore to local forward axis of the game object?

1 Like

Actually transform.forward will always be the Z vector of the object after rotations have been applied. With no rotations, transform.forward would be 0,0,1, but if, for example, the transform was rotated 90 degrees in the Y axis then the transform.forward would be 1,0,0

Vector3.forward is a constant and will always be 0,0,1

If you apply Transform.Translate(transform.forward * Time.deltaTime), the object will move in the rotated direction of the object.
If you apply Transform.Translate(Vector3.forward * Time.deltaTime) the object will move in the postive Z direction regardless of the object’s rotation.

2 Likes

Alright, thanks for the explanation!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms