Entities and components
Everything is an entity
Section titled “Everything is an entity”Open any level and everything in it is an entityentity: A thing in the game world: a player, a ball, a trigger, an empty marker. On its own it only has a name and a place in the hierarchy; components give it behaviour.: a crate, a light, a spawn point, the invisible box that notices you stepping on a teleport pad. On its own an entity is almost nothing, just a name and a place in a tree. What makes a crate a crate is what’s attached to it.
Components make entities do things
Section titled “Components make entities do things”The things attached to an entity are its componentscomponent: One script attached to one entity. The same script on ten entities is ten components, each with its own copy of the script's fields.. Each one adds one ability:
| Component | Adds |
|---|---|
transform |
A place in the world: position, rotation and size. |
model |
Something to see: a 3D model drawn where the entity is. |
physics_box |
Something to bump into: an invisible box players and balls collide with. |
box_trigger |
Something that notices: an invisible box that reacts when something enters it. |
effect |
A visual effect that can be played. |
prefab |
A whole other level, placed here. |
So a crate is an entity with a transform (where it is), a model (what it looks like) and a physics_box (so you
can’t walk through it). Take the model away and you get an invisible wall. Take the physics_box away and you
get a crate you walk straight through.
Every component is a script, and each has its own fields, the values you can change. A model’s main field is
which model to draw; a physics_box’s is how big the box is. You can write your own components too: that’s what
vscript is for.
Entities form a tree
Section titled “Entities form a tree”Every entity has at most one parent and any number of children. A child’s position is measured from its parent, so moving the parent carries the children along.
- hideout_masterthe level
- Propsa group: no components, just a parent to hold things
- crate_01transformmodelphysics_box
- crate_02transformmodelphysics_box
- jump_pad_plazatransformprefabplaces a whole jump pad level here
Levels use empty entities like Props all the time to group things. Move the group and the whole group
moves; hide it in Studio and you can see past it.
Seeing it in Studio
Section titled “Seeing it in Studio”Studio shows a level the way the game sees it:
- The Outliner is the tree. Every row is an entity, indented under its parent.
- The Inspector shows the selected entity: its name and switches at the top, then one section per component, each with its fields.
- The viewport draws the entities that have something to draw, and the gizmo moves the selected one.
Pick a crate in the viewport and its row lights up in the Outliner, and its components fill the Inspector. Change a field and the viewport follows. See Editing a level for the hands-on version.
For programmers
It’s an entity–component model without systems: an entity is a node in a tree, and all behaviour lives in its
components, each an instance of a script with its own copy of the script’s fields. Transforms are local to the
parent. What you set per entity in the Inspector are the script’s constants (plain let fields).
Where to go next
Section titled “Where to go next”- Space and transforms: what position, rotation and scale mean, and why a child moves with its parent.
- Writing a script? Entities from a script shows how a script finds its way around this tree.