How do I reference a variable in a different level?

I’ve been working on a project for an independent study and it’s been going relatively smoothly up until now. I have multiple levels in my game, but I’m trying to reference a boolean from one level blueprint in a blueprint from a different level. The whole objective of this is to press a certain button in one level and it open a door in the next. Does anyone know how I would go about doing this?

Thanks in advance.

As far as I know since I’ve been researching this area recently is you would have to use something called a game instance blueprint to share data between different levels, I was looking at this video here to help me understand how it works:

UE4 - Using Game Instances & Persistent Variables by Gorilla Gong

From what I understand you would create a game instance blueprint and make sure your maps use it, it will contain a boolean variable that you can toggle for your door e.g ‘DoorUnlocked?’. The state of this variable will then stay across the maps.

In your first level after you activate the switch you will use a cast node to your game instance ‘MyGameInstance’ and from that you will set DoorUnlocked? to true. In the second level you will have a get game instance node with a cast to MyGameInstance with a condition set up asking if DoorUnlocked? is set to true, is yes then unlock door, otherwise do nothing.

Hope that helps. :slight_smile:

That is exactly what I was looking for. Thanks for the help.