Path finding (like in Rollercoaster Tycoon)


In Rollercoaster Tycoon, the people in the park find their way from point A (like a coaster) to point B (like a shop) following a single route (so it’s not a random route).

I want to create something like that. I have already made the path-editor, so I can already lay down some path. But can I make the characters find their way from point A to point B with multiple crossroads? I was thinking about creating a node on every crossroad, so the peeps can find their routes through nodes (like in the pathfinding tutorial with nodes), but how can they find their routes?
Maybe there is a better way?

Thanks in advance!

  • Mitch

You could do a search on pathfinding or A-star. Even non-BelenderArtists resources deal with that.
Basicly you need a graph of nodes connected by weighted edges. You already seem to have that, but you need to transform this into a proper form for a pathfinding algorithm (e.g. a dictionary). Then run the algorithm for startpoint and one or more endpoints to get a path. The path is just a list of nodes to follow. The pathfinding can only be done by Python. There is no logic brick for that.

Now let the NPC follow the path. That needs a bit of Python:

  1. take the first node from the list (and remove it from the list)
  • identify the corresponding object/position of the node
  • trackTo this object/position
  • move forward
  • if the NPC is near the object/position start with 1. until there is no node left in the list otherwise the NPC is at the endpoint.

For all this you should find threads at the resource forum. Have a look at the stikies regarding There is a section with links to the logic threads.

this is a simpel A* (A star) algorithm implementation in blender (Spanish)

this is an automatic traslation