Load Several Stream Levels at once

I have several stream levels that I am trying to load at one time. I have all 5 saved into an array. Is there a way to load all 5 at once? I was thinking I could plug it into a ForEachLoop and plug that into a Load Stream Level, but that only loads the first item in the array. So maybe I am misunderstanding how that node works.

Load Stream Level is a latent node, and a for each loop fires off all array elements in a single frame. So when you hit the load stream level node before it has finished loading in the first level it will NOT run again. You need to load them in order that you want.

So what’s the best way around this issue?

Try adding a small delay in your loop before Load Stream Level.

This does not work if you are iterating through multiples. For me it only changed which level was being loaded.

I have a solution for you! This was bugging me as well. Asked around and found a solution.

You need to make an event, then load one map. When it completed, increment your array index and call the event again (as the last node in your custom event).

Attatched is an example.

2 Likes

ForEach loop is a one frame node, which means it’s executed during single tick. No matter how heavy the body is (it would just frop framerate). LoadStreamLevel is a node executed in another thread, which means it can take more than one tick to complete (that’s what clock icon on nodes means by the way). This means it just shouldn’t be possible to execute multiple time during one frame, like you try to do. The result would just be unreliable. I guess there’s a block inside that node, that prevents it from being called again before Completed is called (I am not sure, but maybe it only allocates one specific thread for that function or it’s just a safety feature).

There’s a solution for your question by polygonfuture above. It should work, but it won’t execute during one frame. Levels won’t be loaded simultaneously, but consecutively instead. It’s a much better way of doing this, because it’s much more reliable too (even if otherwise would be possible). If you have some loading screen for all this, you can just remove it after last level loads, also you can keep track of progress (for example if you want to have a progress bar).

And this ladies and gentleman, is why I pay for internet. You just saved me a lot of time.

1 Like

Here is one I made based on the one above, which includes unload. It’s important to have the set integers early in the logic, or if you go back to a previous trigger it’ll still be on a high index.