Game Development Reference
In-Depth Information
Position
Game Object
Transform
Variables
Variables
Variables
x: float
y: float
z: float
...
transform
renderer
...
position
localScale
...
Functions
Functions
Functions
Scale
Normalize
GetComponent
AddComponent
Translate
Rotate
Fig 1.33 The Game Object class
containing a Transform class that
contains a Position class.
Listing 1.27 Changing the Location of a Game Object
with Script
private var gameObj : GameObject;
function Start()
{
gameObj = GameObject.CreatePrimitive(PrimitiveType.Capsule);
gameObj.transform.position.x = 1;
gameObj.transform.position.y = 5;
gameObj.transform.position.z = 2;
}
Note
You can always change the location of a Game Object by typing
values into the Transform component in the Inspector, although this
can't be done while the game is playing. That is why scripting is more
powerful.
Search Nedrilad ::




Custom Search