collider2d
The node's 2D collision shape, chosen by kind. It belongs to the node's body2d or the nearest body above it; without one it is static geometry.
On this page
2d · physics · 23 properties · 2D
The node's 2D collision shape, chosen by kind. It belongs to the node's body2d or the nearest body above it; without one it is static geometry.
In a scene, collider2d is the node key that applies it. A script reaches each property below as a field on node.collider2d: reading one asks the running component, and assigning one leaves the rest alone. The whole table is node.collider2d.get() and node.collider2d.set(table).
Properties
| property | type | default | description |
|---|---|---|---|
center_of_mass |
vec2 | [0,0] |
Where this collider's mass sits, in its own space; read with inertia, and both 0 keep the shape's own |
collision_layer |
flags | ["1"] |
The layers this collider is on One of 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32. |
collision_margin |
float | 0 |
A margin the solver treats as already touching; stops thin shapes tunnelling and jittering At least 0. |
collision_mask |
flags | [] |
The layers it collides with; empty means every layer One of 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32. |
collision_test |
enum | both |
Whether a pair is tested when both colliders' layers accept the other, or when either does; two colliders that differ use both One of both, either. |
contact_force_threshold |
float | 0 |
How hard a contact must be before on_contact_force is called At least 0. |
contact_pairs |
flags | ["dynamic_dynamic","dynamic_kinematic","dynamic_static"] |
Which pairs of body kinds this collider is tested against; a sensor is tested against every kind whatever this says One of dynamic_dynamic, dynamic_kinematic, dynamic_static, kinematic_kinematic, kinematic_static, static_static. |
density |
float | 1 |
Mass per volume, so the shape's size sets its mass; 0 makes a collider that adds no mass to its body At least 0. |
enabled |
bool | true |
Collide at all; a disabled collider keeps its shape and costs nothing |
inertia |
float | 0 |
This collider's resistance to spin; 0 with a center_of_mass takes the shape's own about that centre At least 0. |
mass |
float | 0 |
Mass in kilograms, overriding what density works out to; 0 keeps the density At least 0. |
offset |
vec2 | [0,0] |
Where the shape sits relative to the node |
offset_rotation |
float | 0 |
How the shape is turned relative to the node; radians in the file |
one_way |
bool | false |
A platform bodies land on from the side one_way_axis names and pass through from the other |
one_way_angle |
float | 0.1 |
How far a contact's normal may lean from one_way_axis and still hold the body; radians in the file Range 0–180. |
one_way_axis |
vec2 | [0,1] |
The side a one-way platform holds bodies on, in the collider's own axes: [0, 1] lands them from above and lets them up through from below |
physics_material |
asset · physics_material |
— | What the surface is made of: friction, bounce and how each combines; empty takes a physics_material at its defaults |
sensor |
bool | false |
Detects overlaps without colliding: bodies pass through and are reported |
shape |
variant | {"edge_radius":0,"kind":"rectangle","size":[1,1]} |
The collision shape, and the dimensions or the source that kind reads |
solver_layer |
flags | ["1"] |
Layers for the solver alone: a pair can be detected but not resolved One of 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32. |
solver_mask |
flags | [] |
Which solver layers this one pushes against; empty means all of them One of 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32. |
solver_test |
enum | both |
The same choice for the solver layers One of both, either. |
surface_velocity |
vec2 | [0,0] |
How fast the surface slides along itself, in the collider's own axes: a conveyor belt carries what rests on it |
Asset types this component references: physics_material.
Script functions
Methods of node.collider2d, the handle a node carrying this component exposes. Every handle also has get(), set(table), patch(table), has() and remove().
From physics2d:
| method | what it does |
|---|---|
aabb() -> physics2d::Aabb |
The world-space box the collider currently occupies, from its lowest corner to its highest. |
broad_phase_aabb() -> physics2d::Aabb |
The box the broad phase files the collider under, which also reaches ahead by its body's speculative_distance. |
collider_mass_properties() -> physics2d::MassProperties |
What this collider adds to its body, in its own space. |
collider_mesh() -> physics2d::ColliderMesh |
A voxel collider's outline as points and the segments between them, for drawing it or for spawning the pieces it broke into. |
collider_volume() -> float |
How much area the shape encloses. |
collision_aabb() -> physics2d::Aabb |
The box the narrow phase tests the collider in: its shape's box grown by its collision_margin and the world's prediction distance. |
combine_voxels(Node) |
Tell two voxel colliders on one lattice about each other's cells, so a body sliding from one onto the other does not catch on the seam. Both must share a cell size and a rotation. |
contacts() -> [physics2d::Contact] |
Every contact point on this node's collider this step. Empty for a sensor, which has no contacts by definition. |
crop_voxels(int, int, int, int) |
Empty every cell outside the cells from (min_x, min_y) to (max_x, max_y), both included. A range holding no filled cell leaves the grid as it was. |
handles() -> physics2d::Handles |
The rapier handles behind this node, its body and its colliders. For matching a log line against rapier's own output. |
heightfield_hole(int) -> bool |
Whether a heightfield segment has no ground. |
overlaps() -> [Node] |
The nodes this one currently intersects; rapier reports a pair only when one of the two colliders is a sensor. |
pose_in_body() -> physics2d::Pose? |
Where the collider sits in its body's frame; nothing for a collider with no body. |
set_heightfield_hole(int, bool) |
Remove or restore one segment of a heightfield's ground, numbered from the first height. |
set_voxel(int, int, bool) |
Fill or empty one cell of a voxel collider: digging a hole, or building a wall, while the game runs. |
set_voxel_size(Vec2) |
Resize every cell of a voxel collider, keeping which cells are filled. |
swept_aabb() -> physics2d::Aabb |
The box the collider covers over the next fixed step, from where it is to where its body's velocity and forces carry it. |
voxel(int, int) -> bool |
Whether one cell of a voxel collider is filled. |
voxel_at(Vec2) -> [int] |
The cell a world position falls in, as two whole numbers. |
voxel_size() -> Vec2 |
How big one cell of a voxel collider is, along each axis. |