Any way to reset the streamed level to it's initial state?

So i have a persistent level which only acts as a main menu, and the game it self is on a different sub level.

Now when i load the sub-level with “Open level” node everything works as expected, but the problem is that this node makes the opened level as the new persistent and i lose my video cache (which is loaded in the persistent level to show video ads later on).

If i use the node called “Load stream level” everything works fine for the first run. the problem occurs when trying to reset the game after the player dies. (the reset game simply calls “Open level” or “Load stream level” again)

The streamed level is loaded at the state where the player died and the game doesn’t reset.

is there anyway of resetting the streamed level to it’s initial state each time it’s called?

Thanks

Streamed level will always return to initial state when reloaded.

In my project I use similar setup. I have one persistent level which loading on startup, and contains only main player start, checkpoint actors, and few very specific triggers for tutorial events. Also all other levels are streaming and added to this one.

In my checkpoint actors I have player location, and array of streaming levels names, that must be loaded with this checkpoint.

So, if player quit game, and enter again, it loading levels associated with last saved checkpoint and teleports player to checkpoint location.

If player dies, game gets last saved checkpoint data, read associated levels names, unload them, and load again, to make them in initial state, and teleports respawned player to checkpoint location.

1 Like

Well, if you have some levels as ‘Static’ (see level details documentation), you don’t need to reload them, because they are not changed during gameplay.

Your answer made me realize my mistakes in my project.
I was moving actors on the scene and was wondering why didn’t they get back to their initial position.

Also my actors was spawned in real time, so they we’re not part of the streamed level.

Thank

Hello @IronSuit, I have exactly the same problem… I’m moving actors on my scene and I’m wondering why they don’t go back at their position when reloading the level… Can you explain me why ?

Thank you

I have the same problem, i’m spawning my platform under my character in the level (streaming), when he dies and come back to the player start, the platform is way ahead of him, nothing is reset to it’s initial state.
Was it a mistake to choose level streaming for this situation? If I’m not supposed to spawn directly in the level how should I spawn in level streaming then ?

Thank you very much

Hello @Sneakyfoxfactory & @Lyvenc0pe , i will try to explain what i understood. But please note that what i say is purely from my understanding therefore it might not all correct.

During my testing with level streaming stuff i’ve noticed that we can categorized the actors in the game in two categories.

  1. Actors placed INSIDE the streamed level
  2. Actors Spawned using “Spawn Actor from Class” BP node or it’s c++ equivilent

The first category i’ve yet to find a way to reset them when reloading the streamed level.
Previously my 2d mobile game would reload the level each time the player dies and want to retry again. so i was trying to implement the streaming level but i didn’t find a way to do that.

The second categories is by spawning the actor real time without having them in the streamed level (again this works for my mobile game because i’m making it in the form of endless runner genre, you have to see if this is possible for your game).

I know it’s much easier to just reload the level once the player dies to replay the game with all the logic reset and the player is in the start condition. but believe me doing it all in real time and resetting the game in real time without reloading the level is much better performance and experience wise.

My game now runs and loads much much faster because i only load the level when launching the game only.

So the way i implemented this real time actor spawning is by making a custom event in the GameMode called “Start New Game” (you can put any other name) and i just need to call this function whenever the player needs to retry the game.
This event starts by the node “Get all actors with tag” (I have tagged all actors that i spawn in real time with a certain tag) and then using for each loop i destroy all those actor to erase them from the previous session. Then after deleting all actors i relocate the player character actor to the initial location. Then i spawn the new actors in the new session.

Regards

IronSuit

Hello @Lyvenc0pe , please check my above reply for to know what i did exactly to get me game working without using any level streaming.

But basically you would want to make a custom event to be called each time you want to reset the game to it’s initial state.

Things to include into this event

  1. Collect all previous actors from your previous session (Using “Get all actors of class” or “Get all actor with tag”) note: for tag to work you need to specify a tag in the actor’s BP.
  2. Do a “For each loop” for the collected actors then do a “Destroy actor” to remove all actors from the sessions.
  3. Reset the player location to it’s initial position.
  4. Spawn New actors into the new session
  5. Also don’t forget you need to reset all other logic varables (For example you need to reset the “Do once” “Gates” nodes you have in you game) You basically have to treat this as a fresh start and you need to reset everything that you use in your logic.

I made my game logic around the concept of reloading the whole level when player retry the game, (Which was easier to tackled for a beginner like me since all Boolean and other variables reset to the default value) its much faster for prototypes. But each time i retry my game i need about 1-2 seconds to load the game again.

It took me about 3-4 hours to reset all of the default values and fix some of my logic errors to accommodate the new resetting method (Reset in real time without reloading the level). But believe me when i say it was the best 3-4 hours I’ve spent on my project. My game now is much faster and the user experience was improved a lot.

Please note that my game is a simple 2d mobile game, and all what i wrote was the best possible solution for my game, i don’t know if it’s beneficial for your game or not (Only you know that). But now you know another way of approaching a the retry mechanics in mobile game.

Regards

IronSuit

Thank you very much for your answer, it was indeed a variable problem. I didn’t reset the spawn point of my course, and it was way ahead of the player when he respawned. I’m also working on a 2D mobile game, and I guess our problems were pretty similar! :slight_smile:

Thanks again,

Liv