Hi guys, with Transform.up, why does the script reference say it is in world space?
Is the reference wrong or is there something I’m not understanding correctly?
Much thanks!
When you use transform.up/right/forward, it means you’re thinking in your local space, but the output is in world coords.
Suppose you’re leaning a little to the right. The tip of the blue arrow is 1 unit along your up. But “for real” it’s 0.5 X and 0.86 Y. transform.up
converted “(0,1,0) my local” into “(0.5, 0.86, 0) world.”
All the transform-dot-directions are really shortcuts. Suppose you want to move 3 right and 2 up. It would make sense to write that as (3,2,0), as long as you remember those are using your arrows. To use it, your have to convert into the real xyz, using: transform.TransformDirection( new Vector3(3,2,0) );
. That converts local to world. The output is how to get to that exact same spot, but using the real xyz axis. A tricky part is, how do you know (3,2,0) is local? Because when you made them, that’s what you were thinking. How does Unity know? Well, you put them inside a transformDirection, so they better be.
transform.up
is really a shortcut for transform.TransformDirection( Vector3.up );