Collider
A solid shape that blocks movement, or an outline traced around art for a closer fit. Walls, floors and anything a character stands on or bumps into.
On this page
Add it
+ Add node → Block, Collider, Sprite Shape creates a node with it already on. Already have a node for it? Add component → ColliderComponent.
From a script
A script on the same node writes these fields by name. ColliderComponent is the name to pass.
rgs
set_point("ColliderComponent", "size", vec2(64.0, 64.0));
set_number("ColliderComponent", "polygon_step", 32.0);
set_point("ColliderComponent", "offset", vec2(0.0, 0.0));
set_flag("ColliderComponent", "solid", true);
set_flag("ColliderComponent", "one_way", false); Fields
| Field | Script name | Kind | Default | What it does | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Kind | kind | one of Rectangle, Circle, Capsule | Rectangle | Which shape. | |||||||||||||||
| Size | size | two numbers (x, y) | (64, 64) | Size in local units. | |||||||||||||||
| Polygon | |||||||||||||||||||
| Outline | polygon | section | empty | Points replace the box; empty leaves the box alone. | |||||||||||||||
| Step | polygon_step | number, at least 0 | 32 u | How long each collision box is where a slanted outline, or a solid circle or capsule, is cut into boxes: in the node's own units, or the world's on a turned node. Shorter follows the curve more closely and costs more boxes; zero cuts nothing, so a round solid is about its box again. | |||||||||||||||
| Offset | offset | two numbers (x, y) | (0, 0) | Offset from the node origin. | |||||||||||||||
| Solid | solid | checkbox | on | Whether this blocks movement. Off, it stops nothing and notices nothing: an Area is what notices bodies. | |||||||||||||||
| One Way | one_way | checkbox | off | Only stops a body falling onto it from above. | |||||||||||||||
| Layer | layer | number | 1 | Which collision layers this is on: what the collision matrix, casts and queries go by. | |||||||||||||||
| Include Layers | include_layers | number | 0 | A body on one of these layers meets this whatever the collision matrix says. It is not put on them. Exclude Layers beats it. | |||||||||||||||
| Exclude Layers | exclude_layers | number | 0 | A body on one of these layers passes through this. It stays on its Layer. Beats Include Layers. | |||||||||||||||
| Material | material | section | none | Friction and bounce; empty stops a body dead. | |||||||||||||||
| |||||||||||||||||||