Direction
Vector3 can define a three-dimensional vector that is referenced by the world axis, vector3.forward,vector3.up,vector3.right the unit vector of the z,y,x axis direction of the object's world coordinate system, or the three-dimensional unit direction vector, which is the vector
This.transform.forward,this.transform.up,this.transform.right corresponds to the unit vector of the current object in the z,y,x axis direction of the local coordinate system, or the three-dimensional unit direction vector, which is the vector
Distance
Update () {
float distance = This.first_move_speed * time.deltatime;//The distance traveled per second, is a scalar
......
Attention
Three-dimensional unit direction vectors multiply scalar distances to be used as a three-dimensional vector with length and direction
Moving translate functions (scalar in x-axis direction, scalar in Y-direction, scalar in Z-direction, specified coordinate system) can represent
The move function is a three-dimensional vector parameter
The addition and subtraction of object position is measured in three-dimensional vectors.
Method One
This.transform.Translate (0, 0,-distance, space.self);//local coordinate system for reference system
This.transform.Translate (0, 0,-distance, space.world);//World coordinate system for reference system
Method Two
This.c_ctrl. Move (-this.transform.forward * distance),//,this.c_ctrl is Unity's own character controller, in parentheses is a three-dimensional vector, three-dimensional unit direction vector by the scalar distance, the local coordinate system for the reference system
This.c_ctrl. Move (-vector3.forward * distance);//World coordinate system for reference system
Method Three
This.transform.position+=transform.forward * distance;//does a three-dimensional vector addition, three-dimensional unit direction vectors multiply the scalar distance, the local coordinate system is the reference system
This.transform.position+=vector3.forward * distance;//World coordinate system for reference system
About the movement of objects in unity in the corresponding direction of the local and world coordinate systems, respectively