Start() Function in Unity
Notes:
Start() Function in Unity:
5. First frame of the scene is created
Start method:
- is called after Awake, OnEnable, OnApplicationPause & OnApplicationFocus;
- is called only once in a script life cycle
- is executed only if script is enabled
- is best for initializing the current object’s properties or variables; which depend up on other object’s property or variable value.
- if you want to initialize the current object’s properties or variables, which depend up on other object’s property or variable value, then you must initialize them inside Start method because Start methods are called after all Awake methods.
Ex: If you want to initialize the player velocity same as enemy velocity, then initialize enemy velocity inside Awake method of enemy’s script and initialize player velocity inside Start method of player’s script because here player’s velocity property depends upon enemy’s velocity property value.
Example code:
void Start()
{
Debug.Log ("Start");
}