I’m building a top-down base-builder (think Dwarf Fortress, Rimworld, and games of that ilk). I’m having trouble figuring out how to generate the terrain procedurally, given that:
I want to have multiple z-levels
I want there to be a link between z-levels, so for example if level 0 has an area where there is a hill, then level 1 should have the surface of that hill in the appropriate place and/or another level going up to another tier
I’ve hunted around online, but none of the tutorials and articles I’ve found really cover this scenario and I’m not even sure where to start.
Can anyone give me some advice or point me towards some appropriate resources? I’m feeling a little out of my depth.
Don’t think of it as 2D, think of it as 2D slices of one 3D terrain. There’s a bunch of resources on creating procedural 3D terrain – take the principles of those and convert it to generate a bunch of 2D slices instead of a 3D mesh.
Might want to give my addon a try. It’s tile based, so it naturally slices into levels, but can link between levels. Here’s an example of it used to make an undulating terrain.
As you can see in the tutorial, the slopes are tiles that occupy two levels at once, connecting them. The same trick can be used for internal staircases, etc for an underground fortress.
Wow, Boris, that addon looks like it’s got so much of what I’m looking for! Just a few questions before I go and buy it:
1/ Does it support (or at least not disallow) runtime changing of tiles? Say, if a slope gets dug into, the slope tile becomes a plain ground tile.
2/ Does it support seeded generation, where you can enter a given string and always generate the same map?
3/ My understanding is that this would require a 3D game setup, right? Given that you know what kind of structure the terrain generation produces, do you have any ideas or suggestions as to how I could best adapt that to a top-down 2D game, where each slice / layer gets treated and viewed individually?
The tiles are just gameobjects after generation. You can do what you like with them.
At the moment it cannot be seeded. That’s a feature I need to add later.
It is designed for 3d, but you can make it work with 2d. The default behaviour after generation is to Instantiate game objects, but it can be overriden. For example, you could just fill an array, then do what you like with the array.