Simple Blueprint communication. Please Help.

Well met,

All I want is to be able to change a variable in one blueprint from a different blue print.
The only way I have managed to get this right is when objects overlap. But I just want one blueprint to simply communicate and update with another one real time.
I’m sure this must be easy, but every tutorial on the subject seems convoluted and uses overlap.

Also, when I get this right, I would like to be able to keep a variable alive across levels. Is there a parent blueprint to the levels, so I can store it there. Global variables would be extremely useful :).

Please help in any way you can.
Thanks
Kevin Manthe

IIRC you can use Gamestate to save global variables (haven’t used it myself yet).

What kind of blueprints do you have, exactly? You will need to have a reference to make the blueprints communicate. Depending on how your game works, it’s as easy as just setting the reference in the editor. But if the blueprints are procedurally generated, you need something else, like a linetrace or an overlap.

This is a good presentation of the three types of blueprint communication:

@Kmanthe2

Make a Blueprint extending GameInstance and set it for you game as the GameInstance class to use. Put your variables here that you want to remain between levels. The Node GetGameInstance will get the GameInstance from any blueprint, then cast it to whatever you called yours.

The first part of your question doesn’t really make sense. All you need is a reference to the Blueprint that you want and you can call functions, events and set variables on it. There doesn’t have to be “communication”.

You need to decide how to get the reference. This depends on what type of Blueprint it is, if it’s an object in the level that you interact with then use the best method that makes sense, such as if the player bumps into it, shoots it, or a mouse click on it etc. That is up to you to decide.

If it’s an invisible thing that just stores some sort of GameState, honestly you’d be better off extending the GameState class and putting your variable’s and functions there. You can get the GameState at any time with the Node GetGameState, then cast to what you called yours. You need to set your game to use your custom GameState class.

There are hacks you can do, like GetAllActorsOfClass and just use the first one, but that’s sloppy and it’s possible you will have more than one instance and they you will start to get weird bugs.

Thank you guys so very much! Game Instance is exactly what I needed.

I needed a separate script to store the score variable that my character was passing, then I needed to be able to send it to my score screen level. Mission accomplished.

Based on @mikepervis answer I found a very helpful video