Advice re: optimisation

Hello,

I’m trying to create a Minecraft - style game. What I want is for the player to be underground and to be able to dig tunnels, passages etc. I want some level of control over how the level is layed out, not just generate a random level a la Minecraft. I also want to be able to give some of the blocks in the level certain attributes. I’m a long way off all this though, I’m still in the process of figuring out how to actually create the blocks and layout the level.

So what I have done is create a 100 x 100 terrain ‘floor’, and then used the Prefab tutorial in the Unity manual to create a perimeter of cubes around the outside edge of the 100 x 100 terrain square. So far so good.

But as soon as I create a lot of blocks (i.e. get the script that generates the blocks to tile the outside wall 50 high) Unity just crashes.

Can anyone make some suggestions on how I can optimise the basic prefab code for creating blocks to stop this from happening? Or are there any other tips I need to take on board?

Thanks,

BoM.

There was a whole thread on this. Search for Minecraft Starter, it was called after playing minecraft. Anyway, I’m making a similar thing to you! Fancy a collab?

I would love to do a collab but I’m the worst person to collaborate with because I don’t have regular Unity3D hours.

My idea is for a game called ‘Goblin King’. You have escaped from the Dwarves prison, you have made your way back to your underground realm - except the stunty dogooders have been a bit OTT with the dynamite. Time to start carving your kingdom out of the rock again.

I have loads of ideas (and not enough time to implement them all).

I did read that thread (and downloaded the guys source code but couldn’t make much out of it). I’ve been reading the Unity manual today and it talks about using Built In Arrays to speed things up, and creating pointers / indexes to objects to speed things up to but I have no idea at the moment how to practically implement these things. Any advice that anyone would care to give (with some simple examples) would be much appreciated. I will give that thread another read though.

If you’re doing something similar then keep me posted, I would be really interested to hear how you’re getting on. I’m @markp3rry if you’re on Twitter.

Cheers :slight_smile:

minecraft doesn’t represent the blocks as blocks. I read an article about the author. Instead he generates his own mesh and only makes polygons for sides that “touch air”.

In addition to that he has some ultra condensed data format for the blocks. He doesn’t store everything in a simple grid. If he did, he’d end up with a gig of data pretty fast. Instead its some form of vector format (like C++ vectors).

minecraft is one of those games that look brutally simple on the surface but are a very heavy task to actually code to the same scope or performance.

That is very smart, and intresting!

Notch is one hell of a beast I must say.

I an thinking that I could try to figure out a way of laying out the level in an array and then try to do something about only rendering the blocks that were within the sight of the player. No idea how to do this or if it will work.