Hello Unity Community! Our student project features an infinite tile map (think Fire Emblem or Advance Wars) except our buildings are 3D. So to start off for testing we simply made it so when the world generator loads in a new chunk of tiles it places prefabs on it (the buildings) according to what type of tile it is. We have the prefabs in an object pool so we aren’t creating and destroying them constantly. But with such a large number of buildings of course the game begins to dip down there in framerate. What are some methods of handling a large amount of meshes like this? A lot of techniques we simply can’t use due to the world generating as you go along and disappearing behind you.
Thanks in advance! 
I am wondering if its the meshes that are your issue, or the draw calls.
When you hit the stats button during gameplay, what is the drawcall count?
Your stats are showing 310 FPS, and your batching seems all right.
When and where is your slow down?
1 Like
Isn’t that a bit low for having a static scene though? There is nothing running at all. Before I added the models it was at 1500, so this was quite the hit. Once characters, AIs, and simulations are running that fps drop will mean a lot. Plus these buildings are only 2 boxes, the actual models will be a fair bit more complex than these.
Well dynamic batching is doing its job currently it appears.
Static batching gives you more efficiency:
But note, things that get moved around, can’t use static batching. If you place it, set it static, and then in game move it. It’ll still render where you originally placed it.
Other than that. Make sure you’re not duplicating materials and meshes and the sort. Always access the ‘sharedMaterial’ and ‘sharedMesh’ properties in code, accessing ‘material’ or ‘mesh’ will create a unique copy. Only do this if that specific object needs its mesh or material to be made unique from all others.
Game logic actually isn’t as expensive as you’d think. Though, yes, it can be… especially physics related stuff. Not sure how physics heavy this game will be, just keep it minimal. Fake the physics where you can.
When it comes to your models. There’s all sorts of tricks you can do to fake detail. In your image you appear to be way zoomed out… well, how high of a poly count do you really need for the models at that zoom distance? Keep that poly count down low.
If you need to have a far away view as well as an up close view, swap out the models when you zoom in. When you get up close you don’t have to draw all the far away models because they’re not in view up close, so you have fewer models with higher poly counts.
And of course, use a good shader that conveys an artistic look you like. For instance with our games we deliberately use low poly models to have a ‘90’s 3d’ feel to our game (ala Sega Saturn or Playstation) but with more colours and better lighting.
It isn’t very physics intensive, if at all, but it is essentially a simulation so we aren’t sure how much juice that will take. And so if something is static it can’t be moved at all? As in, not even once? Sadly we won’t be able to do that then, since the world jumps back towards the origin point (along with the player) as you explore through it to avoid anything getting to positions higher than 100,000 (since the world is infinite that could happen).
I’ve made sure that when the ground mesh’s are generated they delete the temporary mesh object after writing to the mesh filter, but I suppose I could have one mesh built when the game starts and then have every chunk use that as its shared mesh. Never thought to do that. Also, each building is just a prefab, so what would I do about using shared meshes there? If two buildings are the same would it be more efficient to have a mesh stored somewhere that the two of them share, or is that done automatically since they are both the same prefab?
Thanks so much for the advice by the way.
EDIT: Never mind, I can’t use a shared mesh for the ground chunks because they have different UV maps.