Small freeze when spawning actors

Hey Guys!

I’m making a simple shoot em’ up game to learn more about UE4 and there’s a small problem that I’m not sure how to fix:

My game will randomly spawn asteroids and spaceships on screen and the player needs to dodge/shoot them before he’s hit. The thing is, every time I spawn an actor or particle system that was never spawned before, the game freezes for a split second (while it’s loading I think?). This only happens the first time I span an actor, subsequent uses causes no problem. It’s small, but it’s not cool to see small freezes every time a new thing appears or something explodes while you’re trying to dodge a lot of bullets. =(

Am I corrent in assuming that this is happening because the engine needs to load the asset to memory on it’s first use? If yes, is there a way to load everything that will be used beforehand?


I think unless UE4 have some dark magic that allow you to do a preload from blueprint, you probably have 2 choices.

  1. create a level that have a static mesh enclosed all your objects and put it away from visible part of your level.(maybe behind your background plane?)
    make sure they don’t have any AI parts or just have some state to make them disabled.

  2. if you have a loading process, you also stream them in during that waiting period, and destroy them before level begin.

While its unlikely that the assets themselves are causing the ‘loading stutter’, its possible that the issue is caused by your graphics driver having to cache the internal compiled version of the shader for each of the materials that your objects use. Currently UE4 does not attempt to do anything to mitigate these shader pre-draw stutters.