Jump to content
• Advertisement

Public Group

# Collision problem that I've always had

This topic is 4131 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

This is extremely simple, but I'm not sure what the best way to solve it is. Let's say you have a large number of objects in a line, like this:
xxxxx          ooooo
Then, each side starts moving towards each other at a quick speed:
  xxxxx-> <-ooooo
What happens when the middle two collide and then intersect? You can't just move them back, because then you have even more collisions. What am I supposed to do?

#### Share this post

##### Share on other sites
Advertisement
Quote:
 Original post by Daniel MillerWhat happens when the middle two collide and then intersect? You can't just move them back, because then you have even more collisions. What am I supposed to do?

you move them back by how much they are intersecting.

#### Share this post

##### Share on other sites
I think it depends on your collision model. I think one model is:

1) move an object
2) test for collision
3) do collision response
4) goto 2 until there are no more collisions
5) goto 1 until there are no more objects to move

I think there are much more efficient models, but I'm just beginning to learn about that ATM. "Verlet Integration" would be something good to google; there are a few articles about designing physics systems built around verlet integrators.

-me

#### Share this post

##### Share on other sites
Quote:
 Original post by PalidineI think it depends on your collision model. I think one model is:1) move an object2) test for collision3) do collision response4) goto 2 until there are no more collisions5) goto 1 until there are no more objects to moveI think there are much more efficient models, but I'm just beginning to learn about that ATM. "Verlet Integration" would be something good to google; there are a few articles about designing physics systems built around verlet integrators.-me

That's the thing. If more than one object is traveling in the same direction, then you may detect a collision when there really isn't one (because the other object may be moving out of the way). Thanks a lot for your help in this thread and in my RTS thread, btw. :)

#### Share this post

##### Share on other sites
Quote:
 Original post by Daniel MillerThat's the thing. If more than one object is traveling in the same direction, then you may detect a collision when there really isn't one (because the other object may be moving out of the way). Thanks a lot for your help in this thread and in my RTS thread, btw. :)

Maybe you should check into some sort of recursion where each movable object passes it's inertia onto other movable objects it collides with. That way, all collisions will cascade until either the object hits nothing or hits something that is not movable.

 I should mention that this is only theoretical since I've not successfully implemented collision detection, yet. [/edit]

#### Share this post

##### Share on other sites
I've got a demo of two sets of objects moving towards each other in tutorial 4 of Jabuka (shameless plug, see sig).

I'm not currently moving any objects back on intersections, but am unwinding the simulation until I find the time of intersection and then doing the collision response.

"you move them back by how much they are intersecting." I think that the OP's problem is that if he moves only the intersecting objects back, then he'd be pushing them into the objects following the lead object. That's why I'm winding back all objects in the simulation.

If you don't want to do wind back the simulation, lots of people in the Maths & Physics forum have had luck implementing shock propagation via this paper: http://graphics.stanford.edu/papers/rigid_bodies-sig03/

"If more than one object is traveling in the same direction, then you may detect a collision when there really isn't one (because the other object may be moving out of the way)."

My code checks for these situations - if a collision is reported it adds an extra check to see whether the objects are separating, but it does seem pretty clunky.

hope this helps.

#### Share this post

##### Share on other sites
My objects have no inertia, so here is what I'm thinking of doing:

1. Move every object
2. Detect collisions for moved objects
3. If anything collides, move them to a position where they are no longer colliding, and detect collisions again

Thanks for the replies!

#### Share this post

##### Share on other sites
Quote:
 Original post by Daniel MillerMy objects have no inertia, so here is what I'm thinking of doing:1. Move every object2. Detect collisions for moved objects3. If anything collides, move them to a position where they are no longer colliding, and detect collisions againThanks for the replies!

I'd say you don't want to move every object and then check for a collision. You want to move one object, then check. Then move another and check again. And continue doing so until you have moved all objects. This way there's only one possible collision during each check.

#### Share this post

##### Share on other sites
Quote:
Original post by Artum
Quote:
 Original post by Daniel MillerMy objects have no inertia, so here is what I'm thinking of doing:1. Move every object2. Detect collisions for moved objects3. If anything collides, move them to a position where they are no longer colliding, and detect collisions againThanks for the replies!

I'd say you don't want to move every object and then check for a collision. You want to move one object, then check. Then move another and check again. And continue doing so until you have moved all objects. This way there's only one possible collision during each check.

The problem is if I have several units moving in a line. The objects in the back would detect a collision when they tried to move, when in reality there wouldn't be one because the objects in front are moving in the same direction.

edit: it's English now

#### Share this post

##### Share on other sites

• Advertisement

### Announcements

• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
4. 4
Rutin
16
5. 5
• Advertisement

• 12
• 9
• 12
• 37
• 12
• ### Forum Statistics

• Total Topics
631415
• Total Posts
2999966
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!