- Home /
Frame Rate drops when creating mesh in mobile Voxel World?
I have created a game for iPhone which creates a large voxel world similar to minecraft. The world uses chunks of blocks and creates a single mesh for each chunk. As the player moves through the world new chunk game objects are instantiated in front of a player and a mesh is generated for each. Chunks that are too far from the player are destroyed but can be recreated.
However, as each new chunk is loaded, the frame rate drops for an instant creating a distracting pause in gameplay. I have optimised by avoiding drawing faces which are bordered by other voxel blocks. I also calculate the values for the verts, tris and uvs in a separate thread. This has improved performance significantly but the annoying drop in framerate still occurs (even on the more powerful iphone 5S ). I am unsure of what could solve the problem. Possibly the mesh could be added slowly across several frames as there is no great hurry to generate a chunk. Also, adding small meshes to the scene doesn't affect framerate so maybe the mesh could be added in smaller pieces. Any solutions are appreciated. Thanks in advance.
You may get better answers on the Unity Forums. If you post there, include a link in this question so anyone interested can find your question.
Generating / Creating the mesh can happen over multiple frames, which might reduce hiccups. Adding the mesh collider is an expensive atomic operation, meaning it can't be spread out over multiple frames. That might be the source of your hiccup. You could perhaps change your chunk generation logic to use multiple mesh colliders (so that they are smaller) and generate only one per frame.