EQUILIBRIUM
Jun 18, 2025 - Solo School Project - Unity C#
Jun 18, 2025 - Solo School Project - Unity C#
We have a grid of vertices
The player can affect the height of each vertex with a terraform brush
We have a gradient shader
All of this is highly flexible via ScriptableObjects
S.O.L.I.D approach using editor-friendly interface references and a decorator pattern implementation
Instead of checking the brush range against each vertex, we instantly get it by converting brush space to vertex index space, thereby greatly increasing performance
Lower the fidelity of the terrain by spacing out the vertices
By decreasing the amount of times per second the terrain is updated, the overall fps of the game is improved significantly
There are three factions: red, green and blue.
Red chases green, green blue and so forth.
The goal of the game is to make sure all the three factions remain in play for the duration of the simulation.
The player achieves this by terraforming the environment to favor the balance of the ecosystem.
☆ This is the endpoint whereby the calculated vertices are applied to the mesh. By using Physics.BakeMesh, Mesh.MarkDynamic and MeshColliderCookingOptions, the mesh is able to be updated faster.Â
☆ This is how the "brush" changes the terrain. Here, I use TryGetIndexFromPos to convert the Vector3 point into an index.Â
( an index of the vertices array )
Asin: "index = x + z * (maxX + 1)".Â
        private void Claim(int factionIndex)Â
        {
            this.factionIndex = factionIndex;
            rend.material = settings.materials[factionIndex];
            gameObject.layer = firstLayerIndex + factionIndex;
            foodMask = 1 << (firstLayerIndex + Utils.WrapIndex(factionIndex, 1, settings.materials.Length));
            dangerMask = 1 << (firstLayerIndex + Utils.WrapIndex(factionIndex, 2, settings.materials.Length));
            Refresh();
        }
☆ This is how a creature is changed from faction. Notice how the foodMask and dangerMasks are changed using bitshift.
☆ Here is a snippet of how I implemented the decorator pattern.
<--
I started out wanting to make an evolution simulation game. I wanted to give the player the ability to edit the terrain. I ended up getting inspired by that feature and it quickly became one of the main focuses of the game.Â
With coding the project, the main obstacles where working on optimizing the game while maintaining a high degree of flexibility in what terrain the player could create.
I started out wanting to make a game inspired by nature and ending up becoming fascinated by generation and editing these colorful terrain meshes. My way of gamifying this tool was by introducing an ecological element.Â
I prototyped the game by allowing the player to spawn boulder prefabs to simulate the idea of being able to separate different groups of factions away from each other.Â
Through the heavy use of ScriptableObjects, I was able to make many different "biomes" and levels for the creatures to inhabit. Each with their own color scheme, beach pattern and props ( trees, rocks, houses, etc ).Â