Skip to content

Segment Collider

The SegmentCollider defines a line segment between two points. It is useful for thin walls, one-way platforms, and invisible barriers that don’t need volumetric shape.

Properties

PropertyTypeDefaultDescription
point1Vec2{x: -0.5, y: 0}Start point in physics units (local space)
point2Vec2{x: 0.5, y: 0}End point in physics units (local space)
densitynumber1.0Mass density
frictionnumber0.3Surface friction
restitutionnumber0.0Bounciness
isSensorbooleanfalseTrigger zone without physical response
enabledbooleantrueEnable/disable the collider
categoryBitsnumber1Collision filter category bits
maskBitsnumber0xFFFFCollision filter mask bits

Usage

Add a SegmentCollider component to any entity that also has a RigidBody and Transform.

Thin walls: Create invisible collision boundaries without using a full box shape.

commands.spawn()
.insert(Transform)
.insert(RigidBody, { bodyType: 0 })
.insert(SegmentCollider, {
point1: { x: 0, y: 0 },
point2: { x: 0, y: 5 },
});

One-way platforms: Combine with static body type to create edges that objects can land on.

Invisible barriers: Define play area boundaries without visible collider geometry.

See Also