Skip to content

Polygon Collider

The PolygonCollider defines a convex polygon shape with up to 8 vertices. It is useful for custom collision shapes that cannot be represented by boxes, circles, or capsules.

Properties

PropertyTypeDefaultDescription
verticesVec2[][]Polygon vertices in physics units (local space). Max 8 vertices
radiusnumber0.0Skin radius applied around the polygon. Creates a rounded polygon when > 0
densitynumber1.0Mass density
frictionnumber0.6Surface friction
restitutionnumber0.0Bounciness
isSensorbooleanfalseTrigger zone without physical response
categoryBitsnumber1Collision filter category bits

Vertex Editing in Scene View

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

  • Drag a handle to move a vertex
  • Double-click on an edge to add a new vertex (if under the 8-vertex limit)
  • Right-click a handle to remove a vertex

Usage

commands.spawn(
Transform.default(),
RigidBody.with({ bodyType: 2 }),
PolygonCollider.with({
vertices: [
{ x: -0.5, y: -0.5 },
{ x: 0.5, y: -0.5 },
{ x: 0.3, y: 0.5 },
{ x: -0.3, y: 0.5 },
],
}),
);

Tips

  • Keep polygons simple. Fewer vertices means better performance.
  • The radius property adds a skin around the polygon, which can reduce collision jitter for stacking scenarios.
  • For concave shapes, split them into multiple convex PolygonCollider entities and parent them under a single root entity.

See Also