hansgerber7 Posted February 5, 2019 Share Posted February 5, 2019 (edited) 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 February 5, 2019 by hansgerber7 ortography Quote Link to comment Share on other sites More sharing options...
mattstyles Posted February 5, 2019 Share Posted February 5, 2019 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. Quote Link to comment Share on other sites More sharing options...
Milton Posted February 5, 2019 Share Posted February 5, 2019 If your object moves more than 5 pixels, use smaller sub steps (in 1 update). Quote Link to comment Share on other sites More sharing options...
TheAlmightyOne Posted April 2, 2019 Share Posted April 2, 2019 You can use Bresenham's algorithm to create a line of sight sort of check between moves that are larger than terrain obstacle might be. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.