Game dev
Saved & recent

Object lifecycle

Related terms: spawn, initialization, enable, disable, destroy, callbacks

The stages an object passes through: creation, initialization, active updates, disabling and destruction. Engines call lifecycle callbacks at these stages so code can prepare data, respond each frame and clean up.

Initialize before using an object. Subscribe to events when needed, and unsubscribe when finished. Disabling a pooled object is different from destroying it. Callback names and ordering depend on the engine.

Further reading
Unity: Order of execution for event functions
create initialize update disable destroy active updates enable again
Create and initialize the door before its updates begin. Disabling suspends updates and leaves the object available to enable again. Destroying it ends its lifecycle.

View in the full Game dev collection