Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Creation of Zergification tech demo: Creating modular walls

Sign in to follow this  


Outer wall generation

When starting to develop a complex system I like to start with a list of limitations that the system is going to have. You can use every limitation to your advantage.

Limitation 1: Walls have no T or X junctions.
Limitation 2: Walls always for closed loop.
Limitation 3: Walls can only placed on the flat surface.

What are the cons of these limitations ?
The general shape of the walls lacks variety.
Some of the popular patterns that are used in the real world can not be used.

Pros of the limitations?
Drastically reduces the number of modular pieces.
It is very easy to trace along the wall (it will solve a lot of problems in the future)

Now we can start thinking about modularity of the assets. Every wall piece can be described with 3 properties: top type, front type and side type.

Top type
Top type property describes the shape of the peace from top view. Red part of the wall is always facing outside.

Front type
Front type property describes where the piece is vertically. If the wall is taller than 3 pieces, middle pieces can be duplicated without breaking modularity.

Side type
Side type property describes how tall the wall is on the sides.
Some of you might notice that there are no "one lower" condition. I treat it the same way as "same level", because next to it is always a piece with "one higher" condition and i made sure they would connect seamlessly.

So we have 12*3*16=576 variations ... scary number, but we need to remember that not all combinations are valid.
Now we have 12(16+4+1)=252 variations ... still kind of scary. But 252 conditions do not mean 252 modular pieces, we can reuse same meshes and simply rotate and/or flip them. With that in mind it brings us down to 3(10+3+1)=42. Still a lot, but at the moment I could not come up with the method to reduce this number. Later I have found some ways to do it and I used that for road generation. I'll explain them when I'll be talking about roads.


The goal of this class is to take wall array and create a wall out of modular pieces.

Step 1: Randomizing wall height
In order to create a more interesting silhouette I select random areas of the wall and add some height to them.

Step 2: Calculating "Top type" property
At first I take wall array and read it from left to right starting with top left corner. First not empty cell is always L4 type. Then i trace the wall from that point(clockwise), always checking which wall is previous and next cell. This way i can identify type of every piece in the wall. For example I3 type always have previous cell on the left and next on the right.

Step 3: Spawn gate
I grab gate position from city_builder, spawn gate into the world, change height of the wall in the place where it connects to the gate, mark cells that overlap with a gate as "created".

Step 4: Spawn special pieces
In the video that I posted this was not implemented, but in the new version I'm replacing some of the areas of the wall with special peaces, like guard towers at the corners. The procedure is identical to spawning gates, except for the location. I get the location for the special peaces by tracing wall and checking for patterns in "top type" property. For example, if I find the sequence I3, I3, L1, I4, I4, I know that it is the corner and I replace it with the guard tower.

Step 5: Spawn generic pieces
And finally go through the wall array one last time, checking for the cells not marked as "created" and spawn mesh based on 3 properties described earlier.

Step 6: Spawn building builder and send all relevant data to it

Next time I'll talk a bit more about how and where i spawn buildings. Also hopefully by then i'll have new video that will show you some more features.

If you have any questions or you want me to explain something in more detail, don't hesitate to ask.

Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!