How to wait for level load before moving saved actors

Hey,

I’m saving actor data (just position for now) in a SaveGameObject and trying to load them when opening a level. The problem: if I teleport them right after Open Level (called from the game instance), it fails because I assume the level isn’t fully loaded yet, to be more precise it does teleport them but they get sent back to their original location immediately after.

What’s the cleanest Blueprint-friendly way to detect when the level is ready so I can loop through my saved actors and set their positions? I know I could probably do it the dirty way by calling an event inside the “Load from Data” (refer to attached picture) whose sole purpose of existance is to teleport them and restore other variables after a short delay but having a function exist for the only purpose of calling an event that will execute the actual logic sounds like a really effective way to get lost on the long run.

Is there a simpler/more effective solution?

Thanks!

1 Like

Use GameInstance. it persist through map. so all data is loaded from save file into variable in GameInstance then you can use it anywhere

It probably fails, because you have your loading code right after ‘open level’, and ‘open level’ trashes everything in its path.

If you want to use ‘open level’, then you need the rest of the code to run IN the level. An easy way to check that, is from the level BP. Agreed, not portable, but it will tell you what’s going on :slight_smile:

my bad. didn’t read it thoroughly. so yeah, load from data should be in the new loaded level blueprint. you already have game instance so run it there.

1 Like

But that does leave the original problem, to be fair :slight_smile: How to know when the level is loaded?

I don’t think there is a way with ‘open level’, apart from using ‘begin play’ somewhere.

If the level was loaded using ‘load level instance’ then you do get something to bind to

It might be a good idea anyway to let each object load itself, that way, things stay modular, and you get to use begin play.