How do I enable communication between two blueprints?

Is there any ways to pass variables between two blueprints without using level blueprint or event dispatchers ?
I am trying to simply pass variables between a bluprint holding input data and a player controller, or an animgraph and i cannot get anything to work :frowning:

I listened to the Unrealengine4 channel on youtube videos about blueprint communication on youtube and the exemple won’t really fit my needs.

anyone can help me ?

1 Like

Have you tried using a Blueprint Interface?

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/Interface/index.html

Also check out BlueprintComms. With comms you can pass variables directly from one Blueprint to another.

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/BlueprintComms/index.html

This seems to be exactly what I need. But there’s no “TargetBlueprint” in my list. Is this already the result of an upgrade I didn’t get for unsubscribing instantly?

If I understand your goal correctly then the type should be whatever type your other blueprint is. (In the example case this is TargetBlueprint).
So if you have 2 classes:
FirstBlueprint
SecondBlueprint

and you want first to ‘talk’ to second then you would add a variable to FirstBlueprint whoose type is SecondBlueprint.
If you then drag the SecondBlueprint variable into your graph and drag off the pin you should see all the functions you have exposed in SecondBlueprint

Thank you for your answers, i looked at the blueprint comm, the target blueprint could work but the easiest way would be to CAST TO, but unlike the documentation, i found no way to find the Cast To something list.
I tried removing context sensitive, I tried in blueprint, level blueprint or anim blueprint, nothing :frowning:

To Cast to something, you’ll want to drag from the pin of the object you’re trying to cast FROM. In this example, I created my own player controller blueprint called BP_MyPlayerContoller and another Blueprint called BP_Input. Inside BP_Input, I’m getting the default player controller. If I drag off the Return Value from that, I can cast to my own BP_MyPlayerContoller. Then I can access custom variables in that class. Hope that helps!

You should be able to type CAST in menu that pops up and it will provide a list of relevant casts.

How would you do the same thing but without GetPlayerController ?
From my player character, i want to Get a value from a blueprint.

I also relized that Cast To only appears when contex sensitive is checked.

No, this should be core functionality.

Additionally, my understanding is if you unsubscribed instantly you should still get patches until the end of the month. However i’m not 100% sure on this.

The controller is the context in the above case. In your case your probably going to want to drag the variable into the graph window (the variable that is the other blueprint your trying to ‘talk’ to). When you drag you will be given the option of get or set. Choose get. Then drag from the pin in the node it creates.

Still doesn’t work for me - with or without context sensitive.

2759-no%20casting%20here.jpg

:frowning:

In your screenshot the “Current Take Nodes Completed” variable is an INT. The variable needs to be an instance of the blueprint you wish to communicate with. So if you want to call a function on MyShinyBlueprint then the you need a variable in your blueprint whoose type is MyShinyBlueprint. Then when you drag the pin off the GET you should see any functions you can perform on it.

What i did was:
-Create a blueprint object getting the AxisInput each update.
(I tested it by printing in game and it works.)
-I added a variable of that type in my other blueprint

  • I get the value of that variable and print it.

I does nothing.
I guess it’s because my variable is “empty” but how to i set my variable to the other blueprint instance ?
Drag and drop, or sleect and rightclick does not work.

If you put in a Get node you can drag off its output var and get cast to justabouteverything

To avoid your var being Empty do the following:

Hold P and click to add Event Begin Play and hook it up to Get All Actors of Class (gives an array).

Then feed the array var into a GET node and from the GET node’s returned/output var drag out and you’ll see Cast to justabouteverything.

Then drag into the graph your object variable for the class you want to refer to make a Set var on the output of the Cast To … node.

1 Like

I believe TargetBlueprint is what they named the Blueprint in the tutorial.

Now it makes sense, thank you! However, I still didn’t get how to get it working correctly. This is what I got in my HUD:

It always shows me 0/0, even though the values are actually changing inside my player blueprint. I also get these errors for every frame after playing:

2825-456.jpg

Have you set the PlayerBlueprint variable anywhere ? Looks like its null

It’s type is set to “MyPlayer_C” and it doesn’t let me change it’s value.

That’s its type - but you need to set it with the instance of the blueprint you wish to communicate with.
One way you could do this is to add a ‘begin play’ event to your MyPlayer blueprint have it get a pointer to the hud (which you will need to cast if you have a custom hud) and set the PlayerBlueprint variable within your hud from self.