Download

How to keep characters state when Level streaming

I just start making a souls like ARPG game, I split my original Map into several maps using level streaming.
I would like to make a game like Dark Souls, All enemies keep their state before I refresh them.

Enemy characters spawn when I streaming in the new level, enemy characters destroy immediately when I leave the streaming volume.
I want to keep the enemies state after I run away. Because I will back to beaten them again.

I think maybe Level streaming only use for the environment, enemy characters must arrange with level blueprint script.

Is there any good solution?

I think you would want to add a Boolean onto each enemy and keep that as part of the saved game state. So when you load into a level, if the Boolean is false, then that specific enemy will not spawn (defeated), otherwise it will spawn. You could do this dynamically by choosing whether or not to spawn the enemy when the level starts, or even do it from the enemy’s blueprint–say OnEventBeginPlay–IsEnemyDefeated (Boolean)–if yes, then destroy actor–if no, then do nothing or have it continue its normal code.

I’m not sure how to save the variable’s state…say when the player restarts the game–something to look into!

Hope that helps!

Thats a good solution. To go a bit further, you could create an array and save all the states of the enemies to disk. Then when you load your level, have a Spawner Blueprint go through the array and determine who should spawn based on the state.

If you want to fully change levels, then you want the GameInstance. It keeps data in check even when loading a new level.

Thank you for your solution. I need to finish Save Game so that I could dramatically spawn the enemy as the same state ( the same location, die or not, same Hp Mp, even the wooden box is broken or not) when I come back (Not exit game or refresh game state).

Thank you for the document. I am studying how to use it in my project.