Sign in to follow this  
Zaph-0

Need Help with Steering and Collisions

Recommended Posts

Zaph-0    128
Hi, Let me first describe what I need help with: I have a few objects that move along a twisting tunnel. The objects are moving parallel to each other, in several rows and towards the same goal. The objects have a movement direction (2d vector) and a speed and I control them by adjusting those 2 parameters. The problem I am having is that as soon as there is a turn (of which there are many) the objects are all overlapping. The turning and pathfollowing works fine, but sooner or later they all align to the same path and disappear into a single mass of objects. I tried to implement the "Crowd Path Following" approach from "Steering Behaviors For Autonomous Characters " (http://www.red3d.com/cwr/steer/) but I somehow cannot get it to work. I do need some kind of collision detection and logic on how to prevent the overlapping of the objects but still let them move relatively clustered together towards their path. A problem is also that I need to control the objects individually (increase/decrease speed of one that then drops back or races ahead, etc...) triggered by outside events and therefore cannot use a kind of group approach. Did anyone of you do something like this and could give me a few pointers on how to handle this ?

Share this post


Link to post
Share on other sites
alexjc    457
I think all the crowd demos in Craig Reynolds' work use the concept of Avoidance. That's just another steering force. Do you have that in there?

Collision detection is a possible solution, but I don't think it's as simple to deploy as Avoidance.

Share this post


Link to post
Share on other sites
Zaph-0    128
Hi, I tried to implement avoidance by calculating a force vector for all objects in front and altering the course and speed according to that vector but the results were all pretty bad.

Do you maybe have a few more pointers on that topic ?

Share this post


Link to post
Share on other sites
alexjc    457
Actually, I had a brain fart when I wrote that first post. Avoidance would be to move away from walls. I meant Separation, which moves the agents away from their nearest neighbours. It's documented on Craig Reynold's site.

The idea is that it does what a physics collision algorithm would do, but in a much softer way (though not guaranteed to be perfect).


The hard part would be to figure out the strength of the avoidance force, which entities to take into account, and the weight for each one.

Alex

Share this post


Link to post
Share on other sites
Emergent    982
You can put all of this together in a single nice framework by just defining an appropriate potential function and always moving down its gradient. For instance, one that I like is a sum of logarithmic barrier functions (one for each thing I want to keep from happening), and quadratic functions (for each thing I like happening).

-----

The logarithmic barrier functions are of the form

barrier(x) = -log(1 - x)

where x=0 means "constraint not violated at all" and x=1 means "constraint being violated).


The quadratic reward functions are of the form,

reward(x) = -x^2

where x=0 means "good stuff happening."

------

Since your agents presumably cannot move in any direction, they can move in whatever direction moves most down this gradient.

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