Archive for February, 2012

Unity3D + iOS = Mobile Game Experiment!

Tuesday, February 7th, 2012

More explanation to come!

Unity3D Experiments: Minecraft,Voxels,and Me

Tuesday, February 7th, 2012

Minecraft has absorbed an exorbitant amount of my life since I discovered it almost a year and a half ago. If you don’t know what Minecraft is, do yourself a favor and check it out! It’s pretty awesome. The appeal isn’t really apparent at first. A world made up of cubes that you punch / dig to collect… more cubes. The genius is the vast, nearly infinite world that is generated brand new for every map. A whole world of your own to explore, destroy, or build. It is by far the most re-playable game I’ve ever encountered.

My fascination with Minecraft started just after I began messing around with Unity, and thus my two interests began to merge. I was incredibly curious how the developers were able to create such large, randomly generated landscapes that were totally destructible, and also allow you to place objects back. All running incredibly smooth? The answer: Voxels. A term very foreign to me at the time, but is now something I’ve spent far too much brain power  on. I won’t get into a tremendous amount of detail here but essentially a voxel is a pixel with volume. It is a way of representing a 3 dimensional unit of space and information.

Minecraft’s world is essentially a gigantic 3 dimensional grid, where each cell in that grid is designated by a cube. Even the empty areas, the open air, is filled with voxels. Now this information alone is a great start to understanding Minecraft, it’s also where I then jumped over to Unity. Armed with this new found information and fancy voxels I set off trying to recreate Minecraft. I created a 3 dimensional array and proceeded to fill some of the cells with cubes I had brought in. I ran the game and to my chagrin, my computer came to a screeching halt. Turns out there was more to Minecraft than just a shit load of cubes in an array.

This is where I got off the Minecraft development train. I found some people on the Unity forums, who are vastly superior to me intellectually and mathematically, working on figuring out the intricacies of Minecraft and how it works. The post spanned over 50 pages and involved some pretty heady shit. I realized it was time to dial back my enthusiasm and begin on a much finer scale.

By this point I had already created the Trash Can Fighter experiment with javascript and continued on with a 3rd person demo but this time in C#. My goal was to make a miniature demo that captured some of the elements from Minecraft that I really liked, the resource gathering and building.

I set out to accomplish this by created a 2 dimensional array that filled a small play area I had created. I designated each spot in that array a size and value. I then created objects to fill those spots in the array. I created a tree and a rock. I then randomly went through the array and filled it with either nothing, a tree or rock. After I got that working, I created a system where each object could be destroyed when clicked on. When tree’s were destroyed you acquired wood. You could then change over to “build” mode and by clicking the ground, could place a little totem that cost wood. While in the end, it doesn’t resemble Minecraft in any way, I think it’s a good example of my inspirations and dialing back my grand ambitions to something far more attainable and actually achieving it.

You can play the little game by clicking the image below. Remember T toggled between destroy and build! Have fun!

Grid Building and Resource Gathering