DevLog #2.5: Forest For The Trees

Now that we have a world map it would be nice to have it populated with some more decoration – grass, bushes, trees and so on. Let’s have a look at how these are distributed in Flatlings.

In the previous devlog we have seen how the map itself is grouped into TerrainTypes. A TerrainType is a ScriptableObject which holds some general information about the terrain it stands for – a name, an ID, its colour on the mini-map and so on.

TerrainType ScriptableObject for Grassland in Flatlings (2023)

Most importantly, however, every terrain type comes with a list of sprite variants from which the map generator will randomly pick one whenever it generates a HexCell based on this terrain type. These variants slightly differ from each other, so even a couple of tiles of the same type will break the repetition you would get from reusing the same sprite over and over.

The middle row is all forests, promise!

Now obviously those tiles don’t really convey the idea of lush forests and majesticly towering mountain ranges – this is where decoration tiles and elements come in.

The Decoration Element

Like the TerrainType before it, the Decoration Element holds a whole set of different sprites which belong to a specific group – there are element prefabs for grass, trees, rocks and so on, each carrying a whole pool of variants of a certain kind.

These are then placed on a Decoration prefab – this way we can make sure a forest tile will come with a certain range of trees, and a couple of small grass patches in front of it for example.

Accurate but boring

The decoration prefab itself can be set to randomly shift the sprite around within a certain radius, not spawn the sprite if the spawn chance value is not high enough, or mirror the sprite to double the pool of available sprite variants. These options allow for a practically endless number of different tiles without the need of assembling them all by hand.

Each TerrainType has its own Decoration prefab so we can make sure forests will mostly be dense while a plane of grass will be less populated. And once map generation is finished our map segment from above will hopefully look something like this…

See? Forest – told you so!

And now that the whole map is complete and visible, next time we will take a more extensive look at how to make it disappear again.

*woosh*

1 thought on “DevLog #2.5: Forest For The Trees”

  1. Hey Thomas,
    looks all nice and promising.
    Would love to have a walk through the Flatling forest.

    Reply

Leave a Comment