...

/

Initialization and Regular Update Events

Initialization and Regular Update Events

Learn about the usage of initialization and regular update event functions that Unity offers.

To implement most of the gameplay mechanics, we need to be familiar with the event-driven nature of Unity scripting. The scripts created inside the Unity Editor by default inherit the MonoBehaviour class. This class provides access to event functions that can be defined by the developer, through which the gameplay can be implemented.

Event functions

A script created by the developer is not part of the Unity engine itself; instead, the Unity engine passes control to such scripts when some in-game event is triggered. These events are classified into four different categories as follows:

  • Initialization events: These events are emitted when an object is created or enabled; for example, the Start and Awake methods, etc.

  • Regular update events: These events are emitted regularly after some condition is met; for example, the Update, FixedUpdate, and LateUpdate methods, etc.

  • Physics events: All events generated by Unity’s physics engine come under this umbrella. Examples include the OnCollisionXXX and OnTriggerXXX ...