- Home /
Duplicate Question
Generate minecraft alike terrain
When I create a 3D space of cubes, unity gets stuck on starting because of the hard process. I was wondering how games like minecraft or ace of spades, make their games so smooth while generating thousands and thousands of blocks.
An example of code to spawn some blocks:
for(int x = 0; x < 10; x++)
{
for(int z = 0; z < 10; z++)
{
for(int y = 0; y < 10; y++)
{
position = new Vector3(x, y, z);
Block.PlaceAt(position);
}
}
}
As you can see, this generates 1000 cubes, but can't handle this process. How is this done properly? Do you know any guides/links for this?
Thanks
This question has been asked and answered many times. Short answer: you can't instantiate so many game objects, you have to create chunks using the $$anonymous$$esh class. A simple search will turn up much more detailed information.
Follow this Question
Related Questions
How do you save a seed? 1 Answer
Strange random seed issue with level generation 1 Answer
World Generation Instantiate Slowly 2 Answers
pre generated world 0 Answers