Sign in to follow this  
Thanamos

Simulating units 'flooding' a door

Recommended Posts

Thanamos    151

Im working on a small Tower Defence kinda game with a little twist, all of the enemy units will be released at once and it's upto the player to constrict their numbers into tunnels. 

 

Of course I started with all the easy parts like towers and stuff but now I have to write the logic for crowd management, and I am abit unsure if there are any good algorithms for this?

 

Quick example...

 

[attachment=15615:queue.png]

 

Here is 8 units trying to squeeze though a door which only allows one unit at a time.

 

I have already created a A* grid so I know where they are supposed to go, but it's the queue principle im struggling with.

 

Appretiate all the help.

Share this post


Link to post
Share on other sites
alvaro    21247
I am not sure what you mean by "a A* grid", but if you mean you have computed the distance map from each point to the destination (a.k.a. "value function"), you can just use simple steering behaviors for your units, so they stay away from each other but try to advance in the direction that makes the distance decrease. With a little bit of tweaking I bet you can make it look really nice.

If your map is more of a rigid grid, you can still do some discrete version of steering behaviors where a unit moves to the adjacent grid point that minimizes the distance, among the vacant ones.

All that sounds kind of obvious, so perhaps there is more to your question and I missed it. So feel free to ask about anything I haven't covered.

Share this post


Link to post
Share on other sites
Thanamos    151

Steering... exactly what I was looking for.

 

To clarify what I mean about the A* grid is that since the maps are dynamically changed I need to discover the best path to the target, so using A* to get a 'map' of the best path I can use steering to guide all the units along this route.

 

Really appretiate this guys, thanks a million.

Share this post


Link to post
Share on other sites
LancerSolurus    630

Actually I use steering for my AI. Since it is a full 3D environment (outer space) A* isn't a viable solution. In my implementation a straight line is calculated to the target and the AI use 'feelers' to keep from crashing into objects. Eventually the AI will work their way around objects and get close enough to attack if thats their goal. The movement is nowhere near as precise as A* but is is a workable solution in the case of 3D star systems and 3D surface maps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this