tron_thomas at February 6th, 2011 23:23 — #1
I have a situation where there are numerous objects that need to wander about on a 2D plane. The objects should avoid certain areas in the plane and should also eventually make their way toward a desired goal destination.
Where can I find resources that would help with implementing this type of behavior?
reedbeta at February 6th, 2011 23:37 — #2
First of all, google for "pathfinding" and in particular "A* search", which is very handy anytime you need things to move around and avoid obstacles.
If you want things to wander randomly, you could try an approach like: pick a random point within a certain radius (excluding points in obstacles) and path to it. When you get there, pick another random point and repeat.
To make them gradually head toward a goal, every few iterations you could substitute the randomly chosen destination with the goal itself, but then only let them travel a short distance before re-randomizing the goal point. Depending on the obstacle geometry there's no guarantee they wouldn't get stuck in a steady state far from the goal, though.
tron_thomas at February 6th, 2011 23:45 — #3
I have the basic wandering around in a random way figured out.
I have tried using Google to find something that would be useful, and have not run across anything. That is why I'm now posting to this forum.
I don't think I need to resort to something as complicated as A* to solve this problem. I'm not interested in finding an optimal path from a source to destination.
I'm hoping to find something dealing with areas that can attract or repel as object move close to those areas.
rouncer at February 7th, 2011 00:30 — #4
a* isnt complicated.
if you still dont want it, why not just weight their random movements towards the goal, and theyll get there eventually? is that what you want?
alphadog at February 7th, 2011 08:20 — #5
What kind of wandering?
Independent, directed human-like "wandering" (say, people in a city each with their own objective), crowded path (like filing into a stadium), or like a flock of birds (chaotic "follow the leader")?
This may help:
tron_thomas at February 7th, 2011 22:50 — #6
They are supposed to be zombies wandering around in a court yard and slowly making their way into building.
fireside at February 8th, 2011 00:18 — #7
You could pick random directions that have to more or less point toward the door and shift them in random amounts of time. You would need an avoidance system, though.
alphadog at February 8th, 2011 07:25 — #8