Jump to content
  • Advertisement
Sign in to follow this  
unsigned short

Conflicts between steering behaviors

This topic is 3817 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

I have a group of units which I'd like to order to a specific position. So for unit movement I chose a combination of the path follow and the arrival behavior (see steering behaviors by Craig Reynolds). To prevent units from crowding together I also added a separation behavior. But there seem to be a conflict between the arrival and the separation behavior. Because when multiple units try to arrive at a specific position, the separation behavior wants to separate them again and an annoying jittering effect comes up. Does anyone know how to somehow smooth the steering forces in a way that the units stand still when they can't go nearer to their target position?

Share this post


Link to post
Share on other sites
Advertisement
If you have multiple units, place them in a formation. A formation would assign different target points for each unit, e.g. V formation, circle formation, etc.

Then you wouldn't have any "conflicts" as each unit would have its own location...

Share this post


Link to post
Share on other sites
Put a floor on your movement so that if it is below a small value then there is no change at all. Once they get near to that equilibrium, they will simply stand still.

But, formations are cool too - if your design calls for that.

Share this post


Link to post
Share on other sites
Yeah these are possibilities I've already thought about. Formations are a certain problem with my design. Setting a threshold might be a consideration. However, because during the jittering effect the velocity is quite high, the threshold would have to be high too (first arrival behavior with high velocity, next frame separation with high velocity). So both don't really work well:(

Share this post


Link to post
Share on other sites
I think if you've got a group of units trying to "arrive" at a single point as well as separate then you're always going to lose out. Perhaps change your arrival behaviour to bring them to a rest within a certain radius of the target point? I suspect alexjc has the better solution though - proper handling of formations (where every unit has their own destination) would be a better way of handling things.

Share this post


Link to post
Share on other sites
Quote:
Original post by unsigned short
However, because during the jittering effect the velocity is quite high, the threshold would have to be high too (first arrival behavior with high velocity, next frame separation with high velocity). So both don't really work well:(


This implies sharp discontinuities at the edges of the separation and arrival effects, which doesn't sound good to me. At the furthest extent of the separation effect, you'd expect the magnitude of the separation force to approach zero. At some point as you approach the destination, the arrival and separation forces should be roughly equivalent and your jittering would reduce to a level below your threshold.

Another idea is to give each of the units randomised positions near the destination. Pick random places within a certain radius of the target, where the radius is proportional to the number of people you're sending there.

You might also consider some sort of 'step aside' behaviour for units that have already reached their arrival destination, but who end up blocking friends that haven't. The idea would be to move you out of a friend's path, wait for them to pass, and then re-do the arrival behaviour to move back. This could help prevent bottlenecks.

Share this post


Link to post
Share on other sites
You could always add some code that detects that a unit is stuck by simply storing a small history of positions, and checking to see how much the unit has moved over the last few updates. If it's not gone very far consider it stuck and stop trying to move (and maybe recalculate the route if it's not close enough to the destination).

Formations will work well for open maps, but are much more complicated in enclosed areas. For example consider a corridor that is only wide enough for a single unit, if a group arrives in the wrong order some of them will never get to their assigned positions without a lot more work.

Share this post


Link to post
Share on other sites
There have been a lot of topics on here regarding handling the issues with formations. If you go that route (which only partially solves the problem), search for them.

Share this post


Link to post
Share on other sites
If unit A is trying to arrive at point P, check if a another unit is sitting on point P. If so, then calculate a new arrival point somewhere near point P.

Or if it is a group of units, do a leader-follow routine. Designate unit A as a leader and make it arrive at point P. Make the other units follow unit A.

Or, as suggested above do formation.

Share this post


Link to post
Share on other sites
The point of using behaviour based methods is to avoid excessive deliberative checking of entity states against constraints. If you choose a behavioural approach for movement (such as the popular steering behaviours) then it is defeating the purpose to then add state checks to avoid undesirable side effects. Clearly your behaviours aren't working as you had hoped or intended if you find yourself in this position.

It should be mentioned though (as Kylotan implicitly pointed out) that steering behaviours are functionally equivalent to potential field methods. Implementing these in discrete time dynamic programming algorithms leads (in general) to systems with oscillatory transient errors. In simple terms... the system state will not settle to an equilibrium point due to the discretisation of time (and/or space) without the addition of an additional damping term.

What you are witnessing in the jitter is the algorithms attempt to optimise the position of all entities with respect to the steering forces applied to them. This suggests a solution...

Since you are already computing distances to the arrival target it is trivial for you to compute the mean squared distance from all units to the target (sum up the squared distance and divide by the number of units). This represents your position error (w.r.t the arrival behaviour) at the current iteration. You are trying to drive error to zero. Monitor this error over time. If it's magnitude does not change by much over several iterations then it is likely that your system has settled into an optima. If the magnitude is also close to zero then you have settled around the global optima and you can turn off the arrive behaviour.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

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!