Jump to content

Effective AABB collision detection


hansgerber7
 Share

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
Link to comment
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.

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...