The BoxCollider component defines a rectangular collision shape for an entity.
It can be used for both physics interactions and collision detection.
The collider's size is determined by its width and height, and it can be offset and rotated.
Collision layers allow controlling which objects can collide with each other.

const boxCollider = new BoxCollider({
width: 16,
height: 16,
rotation: 0,
offset: new Vector2(),
layer: "CollisionLayer",
physics: true,
ignoreCollisionsWithLayer: ["IgnoredLayer"]
});

Implements

Constructors

Properties

height: number = 0

Height of the rectangle

ignoreCollisionsWithLayers: string[] = []

Ignores collisions with layers in the array

layer: string = ""

Collision layer

offset: Vector2 = ...

X-Y axis offset

physics: boolean = true

TRUE if this collider interact with rigid bodies

rotation: number = 0

Rectangle rotation in radians

width: number = 0

Width of the rectangle