Events

Events are essentially functions used in a distinctive way. Both the Start and Update functions, which we have already seen, would more accurately be described as Unity-specific events. Events are functions called to notify an object that something significant has happened: the level has begun, a new frame has started, an enemy has died, the player has jumped, and others. In being called at these critical times, they offer objects the chance to respond if necessary. The Start function is called automatically by Unity when the object is first created, typically at level startup. The Update function is also called automatically, once on each frame. The Start function, therefore, gives us an opportunity to perform specific actions when the ...

Get Mastering Unity Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.