Scripting Overview
This is a short overview of how scripting inside Unity works.
Scripting inside Unity consists of attaching custom script objects called behaviours to game objects. Different functions inside the script objects are called on certain events. The most used ones being the following:
- Update:
- This function is called before rendering a frame. This is where most game behaviour code goes, except physics code.
- FixedUpdate:
- This function is called once every physics time step. This is the place to do physics-based game behaviour.
- Code outside any function:
- Code outside functions is run when the object is loaded. This can be used to initialise the state of the script.
Note: Sections of this document assume you are using Javascript, but see Writing scripts in C# for information about how to use C# or Boo scrips.
You can also define event handlers. These all have names starting with On, (i.e. OnCollisionEnter). To see the full list of predefined events, see the documentation for MonoBehaviour.
Subsections
Member Variables & Global Variables
No comments:
Post a Comment