Advertisement

Unity 3D: How to minimize game objects on a Huge level/scene.

Started by December 15, 2020 06:18 PM
6 comments, last by Volturna 4 years ago

I'm making an FPS game and I was thinking about how to make my scene very light when it comes to how many game objects are in the scene so the CPU won't get bottlenecked. I believe I'm quite close to the answer, but still not there yet.

Let's assume that I have a big level with a lot of static not interactable objects.

Firstly, I thought of designing the level in Blender, export it as a model, and then import it in unity as a single game object. The problem is that Unity will create nested objects for each mesh of that model, and let's say if that level model has 10,000 meshes then the scene will be overloaded with game objects.

Then I thought of exporting the model as a single mesh, logically thinking Unity will import it as a single game object with only one mesh component, plus the GPU will draw the whole level in a single draw call (since the level is only one mesh) which adds a benefit to the GPU too, but this will probably occupy too much Vram.

So what is the best way to accomplish what I'm trying to do? Is this a known technic that has a specific name?

Thank you for your time!


void life()
{
  while (!succeed())
    try_again();

  die_happily();
}

 

This question is not about Game Design so it has been moved to a more appropriate forum.

-- Tom Sloper -- sloperama.com

Advertisement

@babaliaris Have you tryed combine mesh?

https://docs.unity3d.com/ScriptReference/Mesh.CombineMeshes.html

@sergio cardeira No I haven't, but I would like to avoid coding for this particular problem.

Let's say I have a house. Which one is going to perform better:

  1. Each wall, stairs, and furniture are separate meshes.
  2. The whole house (including furniture ) is made in one mesh, maybe except the doors (so the player can open them)

I know that making things in one mesh, makes the player unable to interact with each one separately, but let's assume he doesn't need to.


void life()
{
  while (!succeed())
    try_again();

  die_happily();
}

 

Note that working with a single mesh you only be able to assign 1 material, so in that case your material will have to contain the house and the forniture, but it will perform better.

If you need 1 material for the house and another material for furniture, you will need a mesh for the house and another mesh that contains all furniture.

It will always perform better the less meshes you have.

For me the best method is to import everything separately to have more freedom and when I have the ideas in place, I use the combinemesh command and create a prefab with the resulting mesh.

Sergio Cardeira said:

For me the best method is to import everything separately to have more freedom and when I have the ideas in place, I use the combinemesh command and create a prefab with the resulting mesh.

So basically all I need to do is copy-paste that code in a script that is attached to the top-level (parent) of the model and it will automatically do everything? Because taking a look at the code, in the Start method, it searches mesh filter components in the children.


void life()
{
  while (!succeed())
    try_again();

  die_happily();
}

 

Advertisement

@babaliaris Almost…check this tutorial its long but it only requires a few lines of code:

This topic is closed to new replies.

Advertisement