Still having BIG problems with corner collisions!

Miscellaneous Forums/General Discussion/Still having BIG problems with corner collisions!

isnt it just ...

you know the ditance the ball was going to move. (moveDistance)
you know the point of collision.
you therefore know the distance travelled to the collision point. (distanceToCollision)

the distance the ball will travel after the bounce would be
moveDistance-distanceToCollision


Of course you better hope you dont have a wall/corner too close otherwise the ball might end up inside another wall/corner.

When I wrote a simple billiards game what I ended up doing was something like this :

1. take Snapshot of all the balls.
2. subTimeSlice = timeSlice.
3. Repeat
4. Repeat each subTimeSlice until totalSubSlices = timeSlice
5. Move each ball by distance of SubtimeSlice
6. If ball collides with something and overlap > TOLERANCE
6.1 then restore balls, divide subtimeslice by 2 and start again from step 3
6.2 else calculate the new velocity vectors for the colliding objects.
7. EndLoop
8. EndLoop

Basically if I overlapped anywhere by an amount > acceptable amount of overlap ( 1 pixel for example ) then I would halve the timeslice and try again.
When the balls collided with anything the collision occured right on a subtimeslice so I only had to calculate the new velocities for the colliding objects. The next subtimeslice(s) would then move the ball and also cater for any other collisions that may occur.

This worked great and meant that even whacking the balls from a break all balls would bounce properly. Of course if things got really busy the game might just visibly slow down slightly but surprisingly it didnt happen often.