Transform Component

From ETC Public Wiki
Jump to: navigation, search


Components of Game Object

Moving an Object

  • Every GameObject has a component called Transform.
  • Transform, controls the position, rotation, and the scaling of that Object.
void Update(){
     // Moving in the forward direction of this Object over time
     transform.Translate(Vector3.forward * Time.deltaTime);


Instantiate an Object

  • Clones the original object and returns a clone.
  • Common use for creating projectiles.
  • Instantiate
void Update(){
     Instantiate(myObject, new Vector3(2.0F, 0, 0), Quaternion.identity);


Destroying an Object

void Update(){
      if(transform.position.y > 11.5)