Entities and Components
All Out games are built around entities (things in the world) and components (behavior/data attached to entities).
If you’ve used Unity before: think “GameObject + Components”. If you’ve used Roblox: think “Instance + Scripts/Components”. The core idea is the same: you compose gameplay by adding components to entities.
Entities
Entities exist in two common ways:
Placed in the editor: they’re already in the scene at startup.
Created at runtime: you spawn them from script.
Creating and destroying entities
entity := Scene.create_entity();
entity.set_local_position({10, 20});
entity.set_local_scale({2.5, 2.5});
entity.set_local_rotation(0);
// When you're done:
entity.destroy();Parenting runtime-created entities
Use keep_world_transform=true to preserve the child's world position, rotation, and scale when changing its parent:
Pass false to keep the child's local transform instead. Pass null as the parent to detach it.
Iterating entities
Components
Components are the units of behavior. A component “lives on” an entity and can read/modify that entity.
Getting and adding components
add_component calls ao_start() before returning. To initialize fields that ao_start() reads, pass a callback; it may capture locals from the caller:
Iterating components
Built-in components you’ll use a lot
Sprite_Renderer
Prefabs (Prefab_Asset)
Prefabs must be created in the editor. In scripts, you instantiate them.
The initialization callback runs before components on the prefab are started. It can be passed with either the default or an explicit position:
Spine (Spine_Animator)
If you’re using 2D animated characters, you’ll often work with Spine_Animator. See Spine.
Writing a custom component
Make new components in dedicated files (e.g. orbiter.csl) and attach them to entities either:
Manually in the editor, or
At runtime with
entity.add_component(...)
Components can implement lifecycle callbacks:
ao_start()ao_update(dt)ao_late_update(dt)(after all updates)ao_draw(dt)(cosmetic-only; renderable frames)ao_end()(when destroyed)
ao_draw skips resim. Gameplay and interactive UI must use ao_update/ao_late_update, never ao_draw.
Example:
Serialized fields (@ao_serialize)
Use @ao_serialize to expose a field in the Inspector and include it in scene and JSON serialization.
Triggers and proximity queries
Trigger colliders expose on_trigger_start, on_trigger_stay, and on_trigger_end callbacks. See Navmesh and Collision for setup and callback signatures.
Use proximity queries when you need every component in a radius or only the closest one.
Useful helpers:
Example:
Best practices
Per-player state belongs on
Player. Avoid global variables that would break with multiple players.Prefer components for gameplay behaviors. You’ll end up with reusable pieces you can attach to different entities.
Draw player UI from
Player.ao_late_update. Wrap it inis_local_or_server().Use
is_local()only for player-specific visual overrides. Do not change gameplay or UI state inside it.
Last updated