Collisions: Part 1

Now things start to get tricky. My first goal this week was to devise a plan for collision detection/resolution.

Because my game will be axis-aligned, I’m able to stay in the realm of AABB (axis-aligned bounding box) collision detection algorithms. In particular, the one that caught my eye was the AABB Sweep Test. This algorithm uses the Separating Axis Theorem, or SAT, to detect if during the next timestep two AABBs will overlap across all axes before they become disjoint along any axis. If the first time of overlap occurs before the last time of overlap, a collision occurred. Now we can simply return the time at which these two AABBs collided and extrapolate a good approximate of the position of collision.

Next up is the collision resolution. We now have the position of the collision, so we can move the two AABBs to their respective positions at the time of collision. I see a couple options at this point. I could compute the new velocities for each AABB and resume movement and collision detection for the remainder of the timestep. Another method, inspired by this post, involves stopping the current timestep at the time of collision and applying an impulse to the next timestep.

I’ve began implementation on collision detection and I’m still researching the best approach on collision resolution for now, stay tuned for part 2.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>