EdgeCollider

The EdgeCollider component defines a collision shape made of connected line segments, formed from a list of vertices. It can be used for physics interactions and collision detection. See Physics for an overview.

It is ideal for irregular surfaces, slopes, and concave shapes, which a single PolygonCollider cannot represent.

Options

OptionTypeDefaultDescription
vertexModelVector2[][]The vertices that form the connected edges.
rotationnumber0Rotation in radians.
offsetVector2(0, 0)Offset from the entity’s position.
layerstring""The collision layer the collider belongs to.
physicsbooleantrueIf true, the collider interacts with rigid bodies.
ignoreCollisionsWithLayersstring[][]Layers this collider ignores.

Example

import { Transform, EdgeCollider, Vector2 } from "angry-pixel";

this.entityManager.createEntity([
    new Transform(),
    new EdgeCollider({
        vertexModel: [new Vector2(0, 0), new Vector2(16, 0), new Vector2(32, 8)],
        layer: "Ground",
    }),
]);

Add a RigidBody to the same entity to make it move and respond to physics.