• Menu
  • Overview
  • Runtime Classes
  • Enumerations
  • Editor Classes
  • Enumerations
  • History
  • Index
  • Scripting Overview
  • Common Operations
  • Time
  • Accessing Components
  • Accessing Objects
  • Vectors
  • Variables
  • Instantiate
  • Coroutines & Yield
  • Using C#
  • Important Classes
  • Performance Optimization
  • Script Compilation

Overview: Common Operations  

Scripting

Most game object manipulations are done either through the game object's Transform and/or Rigidbody. These are accessible inside behaviour scripts through the member variables transform and rigidbody respectively. So if you wanted to rotate an object 5 degrees around its Y axis every frame you could write the following:

function Update() {
transform.Rotate(0, 5, 0);
}

If you want to move an object forward you would write this:

function Update() {
transform.Translate(0, 0, 2);
}