How to differentiate instances of the same blueprint after reloading a level?

I’m trying to keep some switches activated if they were activated in anytime after the level reloads. The error I found by using Print strings is that once the level is reloaded the game instance does not recognize the switches as the same that were destroyed, it just add new switches to the array. I feel like this is really simple but I’m missing something.

This is my BP_GameInstance:


And this is my BP_SwitchPermanent:


This is my first post here so I hope I didn’t did anything in the wrong way, thanks for your time!

Every time you load the level, it’s a fresh run. The only way you can carry state over between loads is using a save game

Thanks for the answer, however it still does not seem to work the way I intended. Also, I have kept values of variables from level to level using just GameInstance, and the array keeps adding switches when they are activated, the thing I struggle with is that when I reaload the level the GameInstance does not regocnize the previously activated switches as the same ones, instead it add new vars of that type to the array as they were different switches when I activated. What I want is just that when I cast the GameInstance and call the function “Is Switch Activated” it recognizes the switch from the array so the funcion returns true and the switch gets destroyed.

Edit: I disconnected the destroy self node and even without reloading the level the game instance still adding new switches to the array shooting at the same switch, so I think the error is there, in how to differentiate the instances in the level.

How are you reloading the level?

By using Open level by name, I finally kinda fix it using an integer array in the GameInstance and giving each switch that I instantiate an unique integer, even tho it’s not exactly what I wanted

Game instance should do it. It depends what you store in there.

Assigning each object an ID is a good idea. Standard way of doing this.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.