- Home /
Difference between Vector.up and transform.up
Basically my question title says everything related to my question. What is the difference between Vector.up and transform.up?
If I have asked silly question then forgive me but at present I can't able to understand these two terms. Please give some suggestion in this.
EDIT : Whether it create any difference if we use anyGameObject.transform.up?
Answer by fafase · May 13, 2015 at 04:37 PM
Vector3.up is constant and corresponds to the world up so (0,1,0). It is the yellow arrow on hte gizmo in the scene view.
tranform.up corresponds to the yellow arrow on the object and is related to it. As you rotate your object, the gizmo on the object moves and all three arrows change direction (not magnitude, always 1). transform.up, right and forward gives you the vector to which they correspond in world space.
So if no rotation, all three are equal to their world equivalent but as you start rotating, they change. In the case of a character, it is most likely rotating around its transform.up so that vector actually never change.
Got it?
Answer by tebandesade · May 13, 2015 at 04:20 PM
Hi well first of all vector is (x,y,z) an other words a normal vector. Therefore, it will indicate to go up 1 pos in the Y axis. On the other hand, transform has three componentes as well, x,y,z. Nonetheless, the transform could be placed not in the normal (x,y,z) pos we know, but locally it can differ for instance maybe the transform of a gameobject of mine is rotated 90 degrees to the right, therefore the Y transform will be the X vector wise and so on
It will create any difference if your Gameobject's transform is rotated compared to the normal Vector (x,y,z) position . Look at the green arrow( Y's transform position -"up")
It is as a normal vector right? If you do transform.up it will be the same as Vector.up because both are pointing towards the same direction. Yet, if your transform rotates like this
See that the green arrow is pointing right, that is your transform's y coordinate so if you do transform.up it will be the same as doing vector.right.