Collision Look-Ahead - Circles and Squares
in
Programming Questions
•
1 year ago
I know that collision detection is a bit of a FAQ, but I have a specific question.
I have implemented circle-on-square collision detection in a very basic manner. Basically it checks the radius of the circle against the center of the square and then also does a short calculation for the corners.
However, because of the resolution of the check it seems to always encounter corner collisions. The speed ends up being too great for the refresh rate and the circle overlaps the square and triggers a collision on the corner.
So I'm thinking that my physics calculations need a paradigm shit. I should probably stop relying on the framerate to set the speed of animated objects.
I am thinking about moving to a time-elapsed based approach. I can then render based on where the objects should be at a point in time rather than simply updating them based on their acceleration and velocity per frame.
Either that or I will start performing look-ahead calculations to make sure that the next velocity step won't land my object inside of another one. Then doing some kind of calculation to determine where it should end up at the next step. This doesn't seem very good, I'm afraid of causing a jump in animation.
Anyway, I was wondering if anyone had any suggestions. I'm sure that some of you have encountered this sort of a problem and had to work out a solution.
link to my code on github:
1