Handling multiple collisions
I'm in the process of making a simple 2D RTS with C#/XNA. I have been playing around with my collision handling system lately, and am unsure how to handle situations when there are 3 or more units in a collision. I have read a few of the articles in the resources section, notably Dave Pottinger's articles on Coordinated Unit Movement. In my current system, each unit has a CollidingWith List, and after it finds its colliding with units, it runs the ResolveCollisions method. Lets say there are 3 units colliding, like this: A B C A knows its colliding B, C knows its colliding with B, and B knows its colliding with both. But A and C are oblivious to each other. I have thought about having a CollisionResolution engine that would take a group of colliding objects, like A, B, and C, and determine which needs to move and in what direction. However, how would you handle situations when there are 10+ in a collision? Does that get too resource intensive? I could see this happening in the later stages of a game where a big battle is happening and there are 20+ melee units duking it out in a small area. Does any one have any pointers or other articles that I may have missed? My current system works ok, but a little too often I'll have a unit get pushed right through another, and needless to say I don't want this. Sorry for the long post, hopefully it makes sense. Thanks, Jeff
I have several hundred units/objects per map in my game and I handle multiple collision like this: ignore multiple collision. Just doing discrete time step collision pairs seems to work ok. =)
I wouldn't mind hearing the correct way to do it for a commercial release though.
I wouldn't mind hearing the correct way to do it for a commercial release though.
If the space is relatively open and units are fairly sparse, you can do it simply by moving each unit out of its own collisions, and not worry about the multiple ones.
Hi, I'm assuming you're having problems with your collision detection when you're trying to move a group of units altogether and they seem to step all over themselves.
You might want to implement flocking behavior if that's the case and assign the role of the leader to the unit closest to the direction you're clicking at.
Here's a link you might find useful.
http://www.red3d.com/cwr/boids/
You might want to implement flocking behavior if that's the case and assign the role of the leader to the unit closest to the direction you're clicking at.
Here's a link you might find useful.
http://www.red3d.com/cwr/boids/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement