Skip to content

Collision Testing

SolarLune edited this page Feb 2, 2022 · 10 revisions

A BoundingObject is a kind of Node that is used for collision / intersection testing, exclusively with one another. There are currently four kinds of BoundingObjects.

  • BoundingAABB - An axis-aligned bounding box (or cube). An AABB cannot rotate (or rather, rotating it makes for a differently sized cube that is still axis-aligned).
  • BoundingCapsule - A capsule, which can rotate and has a customizeable radius and height.
  • BoundingSphere - A 3D sphere, with customizeable radius.
  • BoundingTriangles - A triangle mesh, primarily used for terrain or other static objects.

Currently, AABB > Triangles and Triangles > Triangles intersections are buggy.

Checking for intersections

To check for intersections, you simply call BoundingObject.Intersecting(otherBounds) to see if an object is intersecting with another. You can also get more detail with BoundingObject.Intersection(otherBounds), which returns an IntersectionResult.

An IntersectionResult is the result of an intersection, and contains information, like the contact point (which currently isn't that accurate) and the MTV (or minimum translation vector). You can use the MTV to easily move the intersecting object away from the other object.

Adding the normal of the intersection to the IntersectionResult is on the to-do list. Ray testing would also be very useful to add, but is currently on the to-do list.

Clone this wiki locally