C# Voxel Tutorial
This tutorial is now out of date, I’ve replaced it with a new updated tutorial here: [Tutorial] c# voxel terrain with infinite terrain, saving and loading - Learn Content & Certification - Unity Discussions
Learn to create editable voxel terrain made famous by MineCraft and used in a lot of recent games! Voxel terrain has really been taking off recently, it’s a great way to create beautiful and interesting terrain and give the player full reign over the environment. It this tutorial we’ll be making almost everything you would expect for a prototype voxel game. We’ll be using Unity’s mesh class to procedurally generate efficient voxel meshes. We start out by making a 2d tilebased platformer terrain to understand generating meshes and storing level data and in parts 5 and 6 we start building chunks of voxels. This is an intermediate tutorial so if you don’t have any experience with C# you’re going to run into a lot of trouble.
So how am I qualified to make this tutorial? I’ve been exploring Unity’s options for procedural meshes and voxel systems for about a year now. I’ve unfortunately moved my focus away from making a voxel game in unity but I feel like it’s an area a lot of people have an interest in that should be easier to get into because it’s not as complicated as it seems.
This is an example of my voxel terrain and by the end of this tutorial series I expect everyone
following along to be able to produce similar results by the end (You can almost do it by the end of part 6).
Note: Everything covered here is supported by Unity Free, Pro will give you some image effects that might
make things look better but the things we’ll make won’t require a pro licence.
-
-
-
-
-
- -Part 1: Generating meshes from code - - - - - - - - - - -Part 2: Level Array and Collision Meshes - - - - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
- -Part 3: Perlin noise for terrain - - - - - - - - - - - - - -Part 4: Destroying and placing blocks - - - - - - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -Part 5: 3d Voxel - - - - - - - - - - - - - - - - - - - - - - - - - - -Part 6: 3d Voxels- - - - - - - - - - - - - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Part 7: Modifying the terrain - - - - - - - - - - - - - - - - - - Part 8: Loading Chunks - - - - - - - - - - - -
-
-
-
-
-
-
-
-
-
-
I’m really interested in feedback (This is my first tutorial series) and will do my best to help if anyone has problems. Taryndactyl has already been really helpful in fixing the first few tutorials of problems and I’m trying to get better at avoiding making mistakes but I still need people to let me know if something doesn’t work, even if you manage to fix it the next guy might not so leave a comment.
There are also a lot of great resources out there about voxel development and other concepts that aren’t necessarily directed at unity or voxels that are still very helpful, here are a few of those:
Let’s make a Voxel Engine: Concepts behind a Voxel engine explained in detail by the developer of Vox.
LibNoise: Using noise functions to do amazing things (Voxel engines use noise for adding randomized detail to terrain)
Save Mesh Created by Script in Editor PlayMode: How to save a mesh generated from code ingame by UnityCoder.com
Pathfinding in unity for voxel structures: Again from UnityCoder.com pathfinding for voxel games
Unity forum’s “After Playing MineCraft” thread: You’ve probably seen this but this is the main thread where people have made MineCraft like games using Unity
Cubiquity: An excellent free voxel terrain asset for Unity
More Voxel Resources: Lastly, UnityCoder.com lists even more voxel resources