An endless cave with topographic style
Time for another test! I really like these watercolors where you see a mountainous landscape, clearly marked by a simple gradient of color. If I mix this with the aesthetics of a topographical map (which I quite like lately), I think I can get an interesting visual to explore.
So how am I going to generate and modify my landscapes on Unity? Let’s start with the basics. An object is represented by a mesh, i.e. a set of triangles arranged together in 3D, to give us an impression of volume. And to create these triangles, all we need to do is to make a matrix of points, which will be connected one by one. Add an extra step of attention here to the orientation, as only one face of these triangles will be able to project a texture and be visible (we don’t want any holes in our objects).
Repeat these steps until we have a plan, and by playing with each point’s elevation, we can create our terrain! Knowing that I can retrieve this elevation from a heightmap, measuring it from the color of each pixel, I can simply draw the shape of my terrain in advance. I’m not inventing anything here. I just follow a lot of Youtube videos, like a good student (e.g. mesh generation and procedural terrain).
Now, mastering the concept, it’s up to me to modify the parameters, make my own terrains, and why not cut them up like ham? To get a better idea of the visual, I model a small submarine, quickly code its movement mechanics, and let’s go to test it.
Not bad! I can see that clean separation and color gradation. I even have a bit of fun and give a futuristic look with my neon green textures, normally used in the editor.
Moving forward, I can improve the prototype a little, give it a bit of atmosphere! To make my life easier, I added a few customization options for generating my terrain tiles. I need to be able to easily change the size of the elevation upwards, downwards too to make the ceiling, define the heightmap that will be taken into account here, or the depth distance between each slice, and so on.
With all these codes, I can arrange my tiles to form a cave. And thanks to a little magic trick involving teleporting the player backwards when he exceeds a certain distance, he’s now trapped in an infinite one!
To make a comfy experience, I add an interface, a bit of sound, work on the lighting and refine the movements, and voilà! I’m really enjoying it and I’m pretty happy with myself! I really feel like I’m lost in the abyss. This graphic adds mystery to the horizon, and the illumination of the surfaces close to my submarine gives me that topographical effect from my terrain.
However, I forgot one little detail. The meshes only project their textures in one direction. So if I turn around, I can’t see anything… So, a bit more work is needed if I want to progress in one direction and another in these tunnels.
But after all, I approve of the prototype! It makes me want to keep working on it. Later, I’ll create real levels, with a beginning and an end, where players have to find their way out. Perhaps with an oxygen limit? Of course, I’d also have to add some decoration, a bit of life and some little fish! And finally, it would be nice to be able to emerge from the depths, to breathe a little and reward the exploration. In the meantime, I’d love you to try out my prototype!
What’s to be learned?
It’s a good tip to take inspiration from what’s around you. You could find some good ideas.