I’m currently making endless running mobile game where performance is very important. I’m spawning blocks (one block = one blueprint) with coins and obstacles… Aproximately it’s about 20-30 objects (static mesh components) in one Blueprint and it’s not good for performance on my Nexus 5. When that Blueprint spawning FPS drops from 60 to 40 and after 1-2 second it returns to 60… So my game from time to time freezes about 1 second… When I remove some objects from Blueprint it works good but visuals don’t look good… Also actor merging resolve that problem but these objects must be separate for example coins which are destroyed after collision with pawn…
Do you have any idea how to resolve this?
First make sure its from blueprints, not from what you want to render. I spawned around 200-300 asteroids with collision, physics and events, and everything was running fine, until i added transparent (additive) frame for them. So it kind of looked like my tablet is slowing down from number of spawned blueprints but it was from rendering all those transparent boxes.
Without picture of few blocks i cannot guess much. But solution could be changing way you spawn them. Instead of suddenly spawning 20, try to spawn them in smaller chunks but more frequently. Easiest solution is to slice your block into 4 sections and spawn each every 10 or so frames. Also split actors (meshes) that are just geometry from ones that player can interact with into 2 separate blueprints. Spawn “static” part before you fill it with interactive. Make as many static meshes into instanced static meshes as you can. For eg if you know what types of blocks come next you could create 10 blocks, and combine all those meshes into groups of instanced meshes. Think about your level as construction line, prepare static part way before you place details and then “engine” just before player enters that block. Also take care of destroying everything, unreal kills actors after 2 minutes or so, kill them all in blueprint.
So in short try to even out spawning.
PS. physics (surprisingly) has much lower impact on performance than animating same actor with interpto. So if you have bunch of rotating or moving objects try to make them all physics with some motors etc.