Spawn of heavy objects freezing the game

I made up a system of chunks that holds 24x24x128 blocks, it uses hierarchical meshes and I deactivated all small stuff to improve perfomance, like cast shadows and overlap, but each time it generates a new chunk the game freezes for 2 seconds or more. Do I need to improve the construction code? Is there a way to spawn the chunk without freezing the game, but causing a frame drop? This is the unique problem I have right now, cuz once the chunk is generated, there is no lag, stable 60 fps, the problem is just while the construction script runs. Also, it is horrible to press compile on the chunk blueprint, it takes around 30 seconds to compile, so you can imagine the lag it can cause inside the game.

Put it simple: The generation of your chunks takes it time, I assume you did nothing special to it so it just gets somehow constructed on the CPU, and the main problem: in your main thread.

So I have 3 ideas:

  • Simplify the constuction code (not much fun and very comlicated)
  • Generate your chuncks in constructor and let them appear how you need it. Thats dependent on the situation, sometimes possible, sometimes not
  • Use not the main thread with Blocking events. I assume you only use BPs? In c++ its rather easy to start another thread/task which not blocks the main thread. In BPs I’m not sure if theres an easy way, it seems there is a way found here but maybe you should consider buying Vega Threading

Thanks for your response. Is there a reason for you not be able to multi thread using bp?