Pixel based collision detection,
Members - Reputation: 122
Posted 11 July 2001 - 04:56 AM
Members - Reputation: 256
Posted 11 July 2001 - 05:09 AM
A few points to consider. Are you using varied time frames, like measuring how long it''s been since the last update and moving your ball accordingly, or are you moving a specific(small) amount each ''frame''. You can have the problem with both approaches, but it''s more likely with varied speeds, because on one frame, you might enter the wall by 10 units, but the next frame only lets you exit by 5 units and then you''re stuck.
What you need to do though is to never enter the wall. When you calculate your collision, you need to break the movement of the objects down so that as soon as they ''collide'', they react, and you move the ball in it''s new direction at the same time.
I''m not sure if that''s clear, but basically, when a ball is going towards a wall, you might be 2 units away in frame 1, and then move 5 units in the next frame, so what should happen is, you check collision with each unit, and on the second check, you get a collision, and bounce the ball back in its new direction 3 units.