Bounding boxes limitations

A good to know limitation

HitboxJS uses the Bounding box system to handle collisions. This means that each element is considered as an horizontal rectangle.

If you have a non-rectangular object, like a circle or a rotated rectangle, its collisions will be detected by a rectangle bounding the element, the hitbox.

Regular rectangles: the hitbox fits perfectly

Rectangle elements: the hitbox fits perfectly

Rotated rectangle: The hitbox is a rectangle bounding it.

Circle: The hitbox is a rectangle bounding it.

This may create unwanted collision detection. To address a part of the problem, you can use conditional detection with a minimum overlap to trigger the event.

Last updated

Was this helpful?