Skip navigation

I have had a game idea brewing in the back of my head for quite some time.  The game involves at some point, being able to place (something like) a road on a terrain.  The player would need to decide when placing a road between two points is advantageous.  Once the decision has been made to place such a road, the player should be able to select a start and end point to the path and have the game do the rest.  Now, its not good enough just to draw a road as the bird flies – obstacles might be in the way and it might be more “expensive” to climb a hill than cross flat land.  Obstacles might be anything from ponds, to buildings, to hill sides too steep to build a road over.

Pair this desire to learn Unity 3D ever since my partner left for a AAA game company causing me to not want to maintain our Game Framework and you get this demo:

As you can see, a path has been drawn around the hill because climbing over that hill would have been more expensive than going around it.


Program Download (PC): TerrainExample


The terrain is 2000×2000 world units large (4M nodes in graph if taken like that, but I step by 5 units when solving).

Arrow keys to move the camera.

First click sets start point and solves the graph. Once graph is solved, mouse move calculates the path from start point to position under mouse. Second click sets the end point as the final path solution – mouse movements will not recalculate after 2nd mouse click. Subsequent mouse clicks start the process over.

Leave a Reply

Your email address will not be published. Required fields are marked *