Collision-free design

As a hobby, I am developing a 2D game. I have a basic collision detection implemented using the dividing axis method. When two objects collide, I project one of them onto the collision along the axis that has the least amount of overlap.

The problem I am facing is that when an object moves pretty fast, the axis that has the least amount of overlap is not always the right direction. Best example: when an object moves down (along the + y axis) due to simulated gravitational attraction and collides with an environmental object close to the "edge" (as on the edge of a cliff). If the object fell fast enough, the axis with the least amount of overlapping winds becomes the x axis, and the object moves sideways along the x axis.

What is the best way to handle fast moving objects? I was thinking about moving the falling object in small increments, which seems to add a lot of extra overhead. I also considered giving the environment objects "preferences" from which the axis projects the falling object, but this seems messy and error prone.

Is there a way to do this without adding a lot of extra overhead?

+2
source share
1 answer

I finally managed to find a good article describing the sweep tests in case someone else stumbles upon this post with the same question. The article is larger, but the link below describes the collision between the axis bounding boxes that I use:

link text

+1
source

Source: https://habr.com/ru/post/1335274/


All Articles