Skip to content

Usage.TimeUpdate Events

JuDelCo edited this page Mar 24, 2021 · 5 revisions

Time Update Events

In order to provide callbacks of the most common loop events (update, fixed update, etc) and for some other advanced ones, there are multiple event structs that can be used to run code at a specific time in the loop of your application.

All these events have a float property called DeltaTime.


Normal update (per frame) order of execution:

PreUpdate > Update > Unity Update > PostUpdate > Unity LateUpdate

Fixed update (per physics tick) order of execution:

PreFixedUpdate > FixedUpdate > Unity FixedUpdate > PreCollisionUpdate > Unity OnTrigger* > Unity OnCollision* > PostCollisionUpdate > PostFixedUpdate


LoopPreUpdateEvent

It will be called before the LoopUpdateEvent. Useful for early logic that you need to ensure that will be run before the Update.

LoopUpdateEvent

The most common event. Useful for any code that needs to be run every tick of your application.

LoopPostUpdateEvent

It will be called after the LoopUpdateEvent. Useful for late logic that you need to ensure that will be run after the Update. In Unity, this is equivalent to LateUpdate in MonoBehaviours.

LoopPreFixedUpdateEvent

It will be called before the LoopFixedUpdateEvent. Useful for early logic that you need to ensure that will be run before the FixedUpdate.

LoopFixedUpdateEvent

The second most common event. Useful for any code that needs to be run every tick with the same frequency. Heavy code that doesn't need to run every normal tick like physics or pathfinding usually goes here.

LoopPreCollisionUpdateEvent

It will be called just after the LoopFixedUpdateEvent and before the LoopPostCollisionUpdateEvent. Useful for logic that needs to be run after the FixedUpdate logic but just before the OnCollision and OnTrigger events.

LoopPostCollisionUpdateEvent

It will be called after the LoopPreCollisionUpdateEvent and before the LoopPostFixedUpdateEvent. Useful for late logic that you need to ensure that will be run after the OnCollision and OnTrigger events but before the PostFixedUpdate event.

LoopPostFixedUpdateEvent

It will be called after the LoopFixedUpdateEvent. Useful for late logic that you need to ensure that will be run after the FixedUpdate, PreCollision and PostCollision events.

Usage

Read the EventBus service API to see how to subscribe to events.

Clone this wiki locally