Skip to content

Behavior.OnStart() Method

Definition

Namespace: Brine2D.ECS

Called once before the first tick of this behavior's lifecycle — guaranteed to run before the first Update\(GameTime\), FixedUpdate\(GameTime\), or Render\(IRenderer, GameTime\) call, whichever occurs first. Use this to perform initialization that depends on all entities and components being present — e.g., looking up sibling entities or caching cross-entity references.

C#
public virtual void OnStart();

Remarks

OnStart fires in whichever pipeline dispatches this behavior first. On most frames the game loop runs FixedUpdate\(GameTime\) before Update\(GameTime\), so OnStart will typically fire during the first fixed-update tick, not the first variable-update tick. If the behavior runs only in Render\(IRenderer, GameTime\), OnStart fires before the first render call. The guarantee is simply: OnStart runs exactly once, before any other lifecycle method on this behavior instance. Unlike OnAdded(), which fires immediately when the behavior is added, OnStart is deferred until the first frame the behavior actually ticks, so the entire entity hierarchy is guaranteed to be initialized.