Massive Lag when looking at spawned actors

Trying to make a simple gamemode. using a simple hexagon mesh and using spawn actor. is there a better way to optimise this for performance as this heavly reduces frame rate


Spawning massive amount of actors is very expensive…the system has to do a lot of stuff that is not just place the hexagons in place. and you will have a lot of complete actors for each brick…even when you kill em the system that cleans the resources (garbage collector) will be pretty busy because of this.

I suggest a different approach…not sure which one but may be particles or you can for example ‘pre-spawn’ a bunch of bricks at the beginning and keep em hidden in an array (so the ‘spawning don’t need to be done all the time’ and then you just can pick hidden pawn bricks and place’ when you have a block of bricks (like I don’t know…20 bricks? 50?) you can replace a lot of the bricks you placed already (and return to the array for reusing) with ONE SINGLE spawn of an actor that consists in those 20 or 50 bricks and then you can recycle the bricks from the array all the time reusing/blocking/replacing in batches…that is called spooling and used a lot.

hope it helps

2 Likes

also if you have collisions (like using the bricks geometry to work as an actual floor) I suggest replace the default mesh collider with a simple BOX collider…same when you replace a batch with a single actor. Just use a single composed mesh with all the bricks and one BOX collider for all or just use a no collider version of the bricks and a general box collider for all the group.

When working with massive items you always must consider simplify things all you can and avoid having 500.000 actors with hexagonal collider and expecting great performance.

1 Like