Original connection:
http://blog.csdn.net/kaluluosi111/article/details/17206655
There are 2 forward in the Unity3d, one is Vector3.forward and Transform.forward, and these two forward are actually quite different from each other. The difference between them is mainly reflected in the different coordinate system.
We compare the performance of the forward of the Vector3 and transform two vectors in the self and world coordinate systems, and we use the Transform.translate function to verify. .
Note: self-coordinates! = World coordinates means that the two coordinate systems do not overlap.
Self own coordinate system--space.self
Vector3.forward
Transform.forward
I am confused here, why the Transform.forward turn to their own coordinates will have such a strange result.
After drawing the picture above, I finally understood.
The transformation of the Self's own coordinate system is this:
Move the vector you want to convert to the target axis, as opposed to the world axis.
It's in Transform.forward.
So here's a summary of the difference between Vector3.forward and Transform.forward.
The value of Vector3.forward is always equal to (0,0,1).
The value of Transform.forward is equal to the Z axis of the current object's own coordinate system pointing at world coordinates and therefore not necessarily equal to (0,0,1), but its magnitude length is 1.
This is why, when Transform.forward is converted to self's own coordinate system, this is the result.
The situation on the world coordinate system--space.world is the exact opposite.
Therefore, to move the object forward, on the transform.translate () and directly modify the transform.position, the difference is quite large.
Transform.position itself is the world's coordinates.
1, transform.position+= Vector3.forward
is equal to the z-axis of the world coordinates forward.
2, Transform.position+=transform.forward
is equal to the z-axis of the object's own coordinate system.
3, Transform.translate (vector3.forward,space.self)
is equal to the z-axis of its own coordinate system forward.
The effect is equal to 2.
4, Transform.translate (transform.forward,space.self)
The results of the above-mentioned wonderful work are caused by this usage, and it is not advisable to use this usage for special needs.
5, Transform.translate (Vector3.forward,space.world)
is equal to moving the object along the z axis of world coordinates.
The effect is equal to 1.
6, Transform.translate (Transform.forward,space.world)
is equal to moving the object forward in the direction of the z axis of the object's own coordinates in world coordinates (equivalent to the object moving along its own z axis).
The effect is equal to 2.
Unity3d the difference between Vector3.forward and Transform.forward!