Skip to main content
GameDev.net gamedev.net
🔒 Locked

collision detection loop

Started by ttb Mar 29, 2004 at 6:48 PM 0 replies 600+ views
Original Post
ttb
ttb
Okay, here is my collision detection loop: time = time_delta; while (time != 0) { c = check_for_collisions (simulator, time); /* c is the earliest collision */ if (!c) break; integrate (c.time); handle_collision(c.e1,c.e2); time = time - c.time; } integrate(time); I am using the collision response developed in chris heckers articles. So after I detect a collision, I adjust the colliding entities velocities, and then re-check. What happens is that I will get another collision right away, because I moved the entities to the point that they collided. Now to avoid this, I would only move the entities until they where just about to collide [ integrate (c.time * 0.99)]. But this breaks down sometimes and then I get in to an infiniteloop. So I added a collision count, so I would only handle 5 collisions per step. But this doesn''t really solve the problem properly. Any suggestions on how to solve this problem?
MrFreeze
MrFreeze
-Don''t intercept collisions when bodies are moving apart
-How I do it: avoid any collision. Just measure distances between bodies and if a certain threshold is reached, apply collision response. By doing so you know exactly when bodies (or "colliding" features) are moving apart because you have the measured distance vector to compare with the relative speed of colliding features. At the same time you can handle as many colliding features on one body as you want (multiple collisions)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.