Should'nt Transform.Forward Right & Up should be labeled Local Space?

While working on something recently I noticed the documentation for Transform.Forward, Transform.Right, and Transform.Up all say they are in World Space but they are most definitely relative to the Transform.position, so wouldn’t that make them Local Space?

Example: I have an unrotated cube located at (10, 20, 30) the transform.forward position in Local Space should be (0,0,1) and in World Space it would be (10, 20, 31) right?

Then again, if you rotated the cube 90 degrees to the right, Local forward would sill be (0,0,1) and in the World Space it would be (11, 20, 30)

So I guess you could say its using World Space rotation, but Local Space position? Which is pretty strange when you think about it.

Anyone else have any thoughts?

The vectors are not relative to the Transform.position. What gave you the idea that they are?

Uh…just because they are? Go try it yourself! Go into unity, create a cube, set its position to be anything other than world zero, we will use my previous example (10, 20, 30) then create a script and attach it to the cube with the following code:

void Update()
{
    Debug.Log(transform.forward);
}

And the output in the console will be…

(0.0, 0.0, 1.0)
UnityEngine.Debug:Log(Object)
test:Update() (at Assets/test.cs:16)

over and over and over…

Now that vector…zero to the right, zero up, and one forward…what is that relative to? Its obviously not relative to World Zero, the cube is nowhere near 0, 0, 1 in World Coordinates…its WAY over at 10, 20, 30, so its definitely not World Space. The only way a vector of (0.0, 0.0, 1.0) would be correct would be if it were relative to the Local Space of the Cube itself and the script that is generating the debug log.

You’re mixing up direction vectors with position vectors. These vectors are not “a point 1 unit away from the transform in the given direction.”

OH! OK, that makes a lot more sense. Thank you superpig you’re awesome.

1 Like