How do I execute nodes after LoadStreamLevel without losing to race conditions?

Hey y’all,

I’m fighting with Sublevels and need some directions to go please.
So I have a persistent level with a bunch of sublevels that have Sequences (Cutscenes) and I only load them into Level when I want to play those cutscenes.

In those sublevels I have an actor called “CutsceneLoader” which basically gets those sequences so I can control them with my player Blueprint since I can’t access Level Blueprints in UE.
image

This is what the CutsceneLoader is doing basically:

Everything works just the way I want to except when it doesn’t.
After loading the sublevel as you see in the first image I immediately play the cutscene which does work sometimes but gives an error other times.

Blueprint Runtime Error: “Accessed None trying to read property CallFunc_GetSequencePlayer_ReturnValue_1”. Blueprint: CutsceneCamera_SubLvl Function: Execute Ubergraph Cutscene Camera Sub Lvl Graph: EventGraph Node: Play

I thought that the “Completed” property of the “LoadStreamLevel” means that everything got loaded and I can use all actors of that sublevel like I want.
But it seems like there are some race conditions which sometimes work in my favor and sometimes don’t.

So the question is - How do I load a sublevel and play the sequence in it without breaking it sometimes?

Dirty fixes I could think of would be:

  1. After loading the sublevel, make a Delay of 1-2 seconds before playing
  2. In the CutsceneLoader check if Sequence is null. If yes, Delay and try again

I’ve had this. You have to wait until you can see the actor you want, then go for it.

Don’t use a delay, because the amount of time it takes will depend on the hardware and various other things.

Much better to load the level, and the go into a kind of ‘while-delay’ loop, looking every .1 seconds to see if the actor you want is there.

2 Likes

Hey @ClockworkOcean my old senpai!

I tried this:

It still failed though.

Did I misinterpret your answer?
Thanks for replying so fast btw! Means a lot!

PS:
Is it maybe because before checking it I pass the object to another event that checks it?

Click on the right hand end of the error. Which node is causing it.

The code looks ok.

1 Like

Ah, you’re testing the wrong thing

You’ve already accessed the player. That’s not there if the actor isn’t valid.

You have to test the actor variable.

1 Like

Oh man I’m so braindead thank you for bearing with me!!<3

1 Like

Does it work? :slight_smile:

Since its a sporadic bug I’m not sure but I haven’t encountered it yet which is comforting :smile:
I’ll mark it as solved. My trust in you is bigger than my distrust in blackboxes :stuck_out_tongue:
Thanksssss <3

1 Like