Contents
What does Axis-aligned mean in AABB collision detection?
Axis-Aligned means that the bounding boxes of the objects being compared for collision are aligned on both their x and y axes. Take, for example, the two bounding boxes in the image below. The x and y axes of both boxes are aligned, which means we can use AABB collision detection to check for collision between them.
How does the if statement work in AABB?
The if statement checks to see if there was a collision or not. If the collision time was not within 0 and 1, then obviously there was no collision during this frame. Also, the time when the collision first entered should never be after when it exited out the other side. This is checked, and if it failed, then we assume that there was no collision.
How to respond to a collision in swept AABB?
This will be used later on when we want to respond to the collision. A normal is the direction that an edge of an object is facing. Think of a perpendicular arrow pointing away from face at 90 degrees. The return value is a number between 0 and 1 that indicates when the collision occurred.
How to do collision detection in MonoGame with AABB?
MonoGame already has the Rectangle struct built in, so we’ll take advantage of that. Add the following method to the CollisionChecks class. The method itself is simple. It takes in two Rectangle values and then performs each of the four checks for AABB collision detection and returns the result.
Which is the middle player in AABB collision?
Swept AABB is the middle player that will show a lot of the problems that can occur with normal AABB and help understand core concepts used in more advanced collision techniques. This article assumes you understand the AABB algorithm.
Where does the response box go in AABB?
As you can see, AABB has placed the response box on the opposite side of the block. Logically, this makes no sense as it has magically passed through the object. Example 3 shows a destination that doesn’t collide with the object. AABB will assume that there was no collision and the moving box will move through it like there was no collision at all.
Which is an example of an AABB problem?
AABB has a major fundamental problem that may not be visible at first. Take these 3 examples: Example 1: A normal AABB collision. The blue box is where the box is at the beginning of the frame. The green box is where the box is expected to be by the end of the frame. The aqua box shows where AABB will place the box after collision.