Skip navigation

Category Archives: Terrain

I added Cities to my game tonight.  They know their population and base how “big” they are based on it.  Each city has a number of buildings based on the population as well.  The number and size of the buildings grows with the population.  At the moment these buildings are represented by white boxes, but that can change if I ever get some real assets.

 

The really cool trick is that that when a road is placed near a city, all the buildings in that city check themselves and make sure they are not over the road.  If the building does exist over the road, it re-position’s itself.

I have updated my previous example program with textures on the terrain and road generation.

In screen shot 1, you will see the road drawn with a line along the path generated from my previous post about path generation on height mapped terrains.

In screen shot 2, the example program has been upgraded to generate vertex information for the “sides of a road”.  These are marked with small while pylons.

In screen shot 3, a mesh has been generated out of the vertex info and a texture has been applied to it.

 

This brings me to a good starting point for putting together the CatPhone project.  The next step will be making the road segments interact with each other well.

 

Wish me luck.

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

Description:

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.