Skip to content

Chain Collider

The ChainCollider defines a chain of connected line segments. It is designed for static terrain surfaces and complex boundaries that would be impractical to build from individual box or segment colliders.

Properties

PropertyTypeDefaultDescription
pointsVec2[]DiamondChain vertices in physics units (local space). Default: [{x:-1,y:0}, {x:0,y:0.5}, {x:1,y:0}, {x:0,y:-0.5}]
isLoopbooleantrueConnect the last point back to the first, forming a closed loop
frictionnumber0.6Surface friction
restitutionnumber0.0Bounciness
enabledbooleantrueEnable/disable the collider
categoryBitsnumber1Collision filter category bits
maskBitsnumber0xFFFFCollision filter mask bits

Point Editing in Scene View

When an entity with a ChainCollider is selected in the editor, point handles appear in the Scene View:

  • Drag a handle to move a point
  • Double-click on a segment to insert a new point
  • Right-click a handle to remove a point

isLoop

When isLoop is false, the chain is an open path — objects can pass around the endpoints. When isLoop is true, the last point connects back to the first point, forming a closed boundary.

Open chain — useful for terrain surfaces:

commands.spawn()
.insert(Transform)
.insert(RigidBody, { bodyType: 0 })
.insert(ChainCollider, {
points: [
{ x: -10, y: 0 },
{ x: -5, y: 2 },
{ x: 0, y: 0 },
{ x: 5, y: 1 },
{ x: 10, y: 0 },
],
isLoop: false,
});

Closed loop — useful for enclosed areas:

commands.spawn()
.insert(Transform)
.insert(RigidBody, { bodyType: 0 })
.insert(ChainCollider, {
points: [
{ x: -5, y: -5 },
{ x: 5, y: -5 },
{ x: 5, y: 5 },
{ x: -5, y: 5 },
],
isLoop: true,
});

Tips

  • Chain colliders have no volume, so they only collide on one side. Place points in counter-clockwise order for outward-facing normals.
  • Unlike PolygonCollider, chain colliders have no vertex limit — use as many points as needed to define your terrain.
  • For dynamic collision shapes, use PolygonCollider or the basic collider types instead.

See Also