Jump to content

[Unity] Increase performance (terrain generation)?

15 minutes ago I came up with the idea of making a minecraft-like game, so I opened unity and wrote a simple script that generate a chunk of cubes, but of course as you may already figured it out that caused an extremely low frame rate:

1567rb6.jpg

How should I fix this?

(I thought of disabling the internal cubes but that is probably going to ruin the gameplay)

Link to post
Share on other sites

it's totally unrelated to unity, but the only thing that i can think of is to make sure that cube sides are made of triangles, and not actual squares

maybe it was obvious already, but hey, that's my 2 cents

 

or you can merge the inner blocks (the ones we can't see directly) into bigger huge blocks, and then dinamically split them up in small blocks once they become visible or the player needs to break them

Link to post
Share on other sites

it's totally unrelated to unity, but the only thing that i can think of is to make sure that cube sides are made of triangles, and not actual squares

maybe it was obvious already, but hey, that's my 2 cents

 

or you can merge the inner blocks (the ones we can't see directly) into bigger huge blocks, and then dinamically split them up in small blocks once they become visible or the player needs to break them

I guess I could replace 4 cubes of the same type with a single cube, and revert it when the player is able to see them, but still that doesn't looks like the best way to do it.

How does minecraft handle it?

Link to post
Share on other sites

Look up instancing. You want the game to load 1 model (cube) and 1 texture (a run time or manually made large texture divided into grass, rock etc). From that you simply instance cubes and assign different UV values to different types.

You can write a class that encapsulate single instance and gives it e.g. drop or functionality, but that's once you get the FPS up.

Also read a thing or 2 about voxels, since that's what MC is based on.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×