Lifecycle callbacks
Callbacks are entry points invoked by Rustic. Define only those a behavior needs.
When each callback runs
| Callback | When to use it | Variables |
|---|---|---|
OnCreate | One-time construction before startup. | None |
Start | Resolve references and initialize gameplay state. | None |
OnEnable | Resume state when the owner becomes enabled. | None |
FixedUpdate | Physics and deterministic simulation. | dt: required fixed-step seconds |
Update | Input, presentation, timers, and per-frame logic. | dt: required frame seconds |
OnDisable | Pause state when the owner becomes disabled. | None |
OnDestroy | Release instance resources before destruction. | None |
OnStop | Final play-session cleanup. | None |
Lua 5.4
return { Start=function() end, Update=function(dt) end, FixedUpdate=function(dt) end, OnDestroy=function() end }JavaScript and HTML / inline JS
globalThis.behavior={Start(){},Update(dt){},FixedUpdate(dt){},OnDestroy(){}};External languages
Rustic invokes callbacks through each language SDK. Python calls run(globals()); PHP calls rustic_run(callbacks); C and C++ register RusticBehavior slots; C# calls Run and Java calls run with a callback dispatcher; Luau returns a behavior table. External callback names are on_create, on_start, on_enable, fixed_update, update, on_disable, on_destroy, and on_stop. Omitted callbacks are handled automatically by the SDK; frame callbacks receive dt in seconds. Physics runs after FixedUpdate callbacks, including during Frame Advance. Gravity and solid box response work for built-in primitives, but the simulator does not dispatch collision or touch callbacks to any language.