Sign in to follow this  
hansgerber7

Effective AABB collision detection

Recommended Posts

I know the generic algorithm of checking for collisions between two orthogonal rectangles as described here:

https://developer.mozilla.org/kab/docs/Games/Techniques/2D_collision_detection

However let's assume:

  • I have a platform that has a height of 5 pixels
  • For testing I have gravity that lets an object drop at Object.mass * 1.01 ^ step

How do I prevent it glitching through the platform in case the drop velocity of the object is higher the than the height of the platform?

Should I try to anticipiate the distance the object will move in the upcoming step? Or waht are best practices here?

 

Thanks in advance

Edited by hansgerber7
ortography

Share this post


Link to post
Share on other sites

The absolute easiest is ensuring that your objects never move fast enough to pass through other objects in one update/tick, either by reducing possible speed or increasing size.

The alternate is to perform more in-depth collision detection.

One way is that you test for an intersection of two lines, try searching for various algorithms that would let you do that (easiest with two lines, but possible to test intersections between a line of arbitrary length and different primitive—or complex—shapes). One line depicts the movement in the next tick, the other lines relate to the size and shape of the objects you want to test against. This obviously isn't AABB testing.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.