Fully dynamic level, lots of generated meshes


I’m attempting to create a game which will looks like some game “where its good to be evil”.
The goal of the game is to build and control an empire. Your empire is composed of zones, each zone has a floor and walls.
A wall, is a cube shaped mesh thing. A floor tile, is the absence of this cube shaped mesh.

I want to make a “play grid” of 128x128 cubes (meaning, 16k meshes), and since i want it “scrollable” (to make a big map), i want to be able to display 3 grids ( about 50k meshes).
Each of those cubes must be individually clicable .

I tried the fallowing aproaches with 32x32 grids:

  1. Spawning “blocks” as actors. Big mess. The lag is too strong with this one when i play the game, but it looks fine in editor (the blocks arent there but i dont mind)
  2. Adding meshes components in the constructor of the actor who will spawn the blocks . I have no issues when i run the game, but in the editor, all the components are shown in the window, it annoys me, and it makes the editor nearly frozen.

My question is, how should i do this ? Adding mesh components not at construction time but when some special event is triggered ?
I aim myself to make a proof of concept for 3 512x512 grids in my computer before starting anything else.


You’re going to have to set it up with Blueprints where it can use instanced static meshes, otherwise you’ll have a draw call count that’s too high.


please tell me more about instanced static meshes.

  • I have a BP that generates many “Shape_Cubes” as “floor” via AddStaticMeshcomponent in the Constructionscript.
  • Then adds a material and makes this to a DynamicMaterialInstance.

=> So this should be bad / way too many draw calls?

So I need to create a dynamic static mesh, that can be added to reduce draw calls and increase performance?
As mentioned here: How do I Create a Static Mesh Instance in Blueprint - Blueprint - Epic Developer Community Forums)

I’d be thankful for more info about this!

Works pretty good so far.

When I use “AddStatic Mesh” in the construction script to spawn simple “shape_cubes” with a simple small 512x512px texture I can spawn ~1000 cubes, then the editor becomes very laggy and is unusable (even not responding for couple of seconds).

With using StaticMeshInstances I can spawn over 2500 blocks and the editor is still pretty responsive!

However there are some adjustments to my project I need to do, for example if you change the material of a cube, all other cubes of the same instance change the color, too.
But this should be doable.

Right, instancing requires that all of the objects being instanced use the same materials, it combines them into a single object so it can’t do that if they use different materials. With cubes it’s not a problem to combine them since each object is low poly so the amount of memory it uses isn’t very high.

Then its simple i will have as many actors as I have materials.
Can I “de-instanciate” a mesh ?
I will have to “transfer” or “resize” them from actor to actor in order to change the material when the user select the block.