Game Development Reference
In-Depth Information
2.3.3 Translation, Rotation, and Scaling
Three transformations can be performed on an object whether it be in 2D
or 3D: translation, rotation, and scaling.
Translation refers to moving an object and is specified by a vector in the same
way the pirate in the previous section moved across the island. A translation
occurs whenever the x , y , or z values of an object are modified. They can be
modified all at once with a vector or one at a time. To move an object in the x
direction by 5, the Unity JavaScript is:
this.transform.position.x += 5;
To move the object by 3 in the x , 5 in the y , and 8 in the z , in Unity JavaScript it
could be written:
this.transform.position.x += 3;
this.transform.position.y += 5;
this.transform.position.z += 8;
Several examples of the Translate function are shown in Figure 2.13 .
Fig 2.13 Using the Translate function to modify the position of a game object.
Search Nedrilad ::

Custom Search