Communication between 2 level blueprint

Hi,

I have a map that is set with multiple levels.
I wanted to be able to access to a public variable of one of my level blueprint in another one.

How should I do this?

Thanks,

Hi!

For transfer data between levels you can use

SAVE Game
https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/Blueprints/index.html

or GameInstance

I think yI need to clarify my needs.

I’m not looking to transfer data between levels (a new map that I’m loading) but “sub levels” (https://docs.unrealengine.com/latest/INT/Engine/LevelStreaming/WorldBrowser/index.html)

So I have multiple level loaded at once (like in the ShooterGame project), and I wanted to communicate between the LevelBlueprint of those level.

Thanks,

Using GameInstance as a go-between is still your best bet. Last I checked, referencing a variable from the level blueprint in another blueprint is a no go. However, if you send that variable to your GameInstance, and then have your second level BP read it from there, that should work.

Thanks,

That’s sad this is the only way in BP. I was thinking about loop in all levels, try to cast them properly to my “Level Type” and then access the public variable/events etc… but I didn’t managed to get it.

I will try again or go by the GameInstance path… but it’s a kind of bit hacky.

There’s a logical reason why you can’t reference level BP variables from other blueprints. It creates a dependency on that level blueprint existing (and being loaded) at all times whenever the referencing blueprint is present.

So for example, let’s say you have a BP for a clock prop, and you want it to reference the in game time (which you have stored as a variable elsewhere); if you stored that variable in the level BP, that would mean the clock BP wouldn’t work unless it was used in that level, since it would have nothing to reference otherwise. However, if the variable was stored in GameInstance, you wouldn’t encounter this problem, as GameInstance is present all throughout runtime, and persists through level changes.

I’ve used a pretty general example, and I realise your situation is a little bit different as you want to communicate level BP to level BP, but the reason that it’s not possible is the same. I hope this helps.

I feel like declare a static variable in your class of game mode in c++, then we make it :slight_smile:

If you really need to in your level blueprint you can do find actor of class! Fast and works well

open level parameter and paser it

Avoid using level blueprints if you can. Instead develop actor blueprints that perform tasks in your levels.

For eg. if you want door that has trigger volumes and needs some script.
Instead of making that door in level blueprint, you make actor. Then you expose meshes for door, and frame. Then you make generic script that moves door. An you place that whole package in your level. Now you have single place with that code, easier to maintain than 100ths of doors trough all the game in every level.

Now to communicate between levels use game mode blueprint, place all variables there, also save/load function. Then implement autosave and auto load on level change.

1 Like