Jump to content


Random wandering toward goal destination


7 replies to this topic

#1 tron_thomas

    New Member

  • Members
  • Pip
  • 3 posts

Posted 07 February 2011 - 04:23 AM

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?

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 5344 posts
  • LocationSanta Clara, CA

Posted 07 February 2011 - 04:37 AM

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.
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 tron_thomas

    New Member

  • Members
  • Pip
  • 3 posts

Posted 07 February 2011 - 04:45 AM

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.

#4 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2762 posts

Posted 07 February 2011 - 05:30 AM

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?
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

#5 alphadog

    DevMaster Staff

  • Moderators
  • 1716 posts

Posted 07 February 2011 - 01:20 PM

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:
http://opensteer.sourceforge.net/
Hyperbole is, like, the absolute best, most wonderful thing ever! However, you'd be an idiot to not think dogmatism is always bad.

#6 tron_thomas

    New Member

  • Members
  • Pip
  • 3 posts

Posted 08 February 2011 - 03:50 AM

They are supposed to be zombies wandering around in a court yard and slowly making their way into building.

#7 fireside

    Senior Member

  • Members
  • PipPipPipPip
  • 1621 posts

Posted 08 February 2011 - 05:18 AM

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.
Currently using Blender and Unity.

#8 alphadog

    DevMaster Staff

  • Moderators
  • 1716 posts

Posted 08 February 2011 - 12:25 PM

http://www.red3d.com...PathFollow.html
Hyperbole is, like, the absolute best, most wonderful thing ever! However, you'd be an idiot to not think dogmatism is always bad.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users