I have a strange collision detection problem…
A maze of balls ( rows & colums ) and a ball i firing on it.
When the speed of the fired ball is to high i get some strange display results.
the ball overlaps another ball in the maze en that is not entirely correct. They should be stacking like a bubbleshoot game.
Everything works as it should be when i use a low speed for the fired ball.
For the collision i loop the entire maze with the fired ball en when a collision is detected i use a break statement because there is no point in continuing to look for collisions…
Can anyone explain why i get odd result with higher speeds?
Post your code. All relevant parts, only relevant parts.
Well yeah, it’s probably because you’re checking for collisions every frame, and a frame is short enough for two balls, given their speeds, to overlap significantly.
There are algorithms for finding out the exact time a collision would occur, and thus prevents the event of any overlapping by forwarding to the next collision.
Billiards simulation tutorials are a good place to start.
As a side note, I don’t recommend simply upping the frame rate.
I can’t find the site I’ve been using recently…
Here we go (collision detection):
if you have never done vector math or dynamic collision here is a great tutorial to get you started on:
and this is the relevant section for this:
Are you using an overlap based collision system (in the case of balls, for example, checking if the distance between balls is less than their combined radii)? If so, then once the ball starts moving faster than that distance, it’s possible to overshoot a collision or pass through too far and have the collision reposition the ball I the wrong place. Also, sometimes, if you’re using a single loop and returning after it detects a single collision, it’s possible sometimes for it to find a collision within the balls trajectory, but for that collision not to be the closest actual collision, just the first one you encounter in your loop for that frame.
You should post the relevant code so people can try to figure out exactly what’s going on, though, since the problem might be something completely different depending on how you’ve set it up.