# Sharing variables between Blueprints via Interfaces

**URL:** <https://forums.unrealengine.com/t/sharing-variables-between-blueprints-via-interfaces/293963>\
**Category:** UI\
**Tags:** interface, variables, unreal-engine, global, question, Blueprint\
**Created:** [September 17, 2014, 8:44pm UTC](https://forums.unrealengine.com/t/sharing-variables-between-blueprints-via-interfaces/293963 "2014-09-17T20:44:24Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_4071fa6e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4071fa6e1](https://forums.unrealengine.com/u/anonymous_user_4071fa6e1)\
**Post date:** [September 17, 2014, 8:44pm UTC](https://forums.unrealengine.com/t/sharing-variables-between-blueprints-via-interfaces/293963/1 "2014-09-17T20:44:24Z")

</div>

I’ve been looking for a succinct way to share variables between blueprints using _interfaces_.

i.e. **“BLUEPRINT\_B can GET/SET variables declared in BLUEPRINT\_A via a _Blueprint Interface_.”**  
(The communicating blueprints are not be associated with a visible scene object.)

I have already seen the official Blueprint interface docs and [video tutorial](https://www.youtube.com/watch?v=WwfsWr4A894) but only [this post](https://answers.unrealengine.com/questions/6964/getting-a-variable-from-one-blueprint-in-another.html) describes exactly what I wanted to do.

In that particular post, the blueprint interface communication works perfectly between the default _MyCharacter\_blueprint_ and the  
_Actor\_blueprint_.

Under the assumption that _any blueprint_ can communicate with _any other blueprint_ I removed the interface implementation from **MyCharacter** and added it to another blueprint in my project (e.g. a _BP\_SaveGame_).

Unfortunately there is something missing as the communication no longer works and the printed byte value is always zero.

Can someone explain what is missing?

---

<div class="post-metadata">

**Author:** ![alperenakyuz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@alperenakyuz](https://forums.unrealengine.com/u/alperenakyuz)\
**Post date:** [September 19, 2014, 10:38pm UTC](https://forums.unrealengine.com/t/sharing-variables-between-blueprints-via-interfaces/293963/2 "2014-09-19T22:38:22Z")

</div>

All blueprints can talk to each other, provided that they use that specific interface. You need to go to the blueprint properties and add the interface to it.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4071fa6e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4071fa6e1](https://forums.unrealengine.com/u/anonymous_user_4071fa6e1)\
**Post date:** [September 20, 2014, 5:52am UTC](https://forums.unrealengine.com/t/sharing-variables-between-blueprints-via-interfaces/293963/3 "2014-09-20T05:52:24Z")

</div>

Hi alperenakyuz ,  
The interface is already added as shown in the [example post](https://answers.unrealengine.com/questions/6964/getting-a-variable-from-one-blueprint-in-another.html).  
The problem I have (as described above) is something else.

---

<div class="post-metadata">

**Author:** ![PeterLNewton](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PeterLNewton](https://forums.unrealengine.com/u/PeterLNewton)\
**Post date:** [September 21, 2014, 6:51pm UTC](https://forums.unrealengine.com/t/sharing-variables-between-blueprints-via-interfaces/293963/4 "2014-09-21T18:51:37Z")

</div>

How are you getting your BP\_SaveGame variable? Is it a valid object when you attempt to interface with it?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4071fa6e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4071fa6e1](https://forums.unrealengine.com/u/anonymous_user_4071fa6e1)\
**Post date:** [September 22, 2014, 12:17pm UTC](https://forums.unrealengine.com/t/sharing-variables-between-blueprints-via-interfaces/293963/5 "2014-09-22T12:17:34Z")

</div>

I believe so.  
The setup is mostly same as described in the [example][1], except that I:

- (add) implement the interface in _BP\_SaveGame_ instead of his ‘_MyCharacter_’ blueprint

- call the interface from a _BP\_Hud instead_ of his ‘ **Actor** ’ blueprint

I use an EventReceiveDrawHud in the BP\_Hud to trigger the call.  
The default value for my byte value is 123 and that is what I expected to print, but it prints 0, suggesting that it can’t see or access the byte variable.

The only thing that is questionable is my _GetPlayerController-\>GetHUD target for the GetByte()_ interface call.  
(See screenshot).

 ![16000-caller.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/a/9/0a91a615eb7f96ae1468abb6d292a08c6fa9ccf8.jpeg)

I am not using an Actor class with GetPlayerCharacter.

---

<div class="post-metadata">

**Author:** ![PeterLNewton](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PeterLNewton](https://forums.unrealengine.com/u/PeterLNewton)\
**Post date:** [September 23, 2014, 4:52am UTC](https://forums.unrealengine.com/t/sharing-variables-between-blueprints-via-interfaces/293963/6 "2014-09-23T04:52:59Z")

</div>

Okay so I see the issue. You are trying to get the Byte from the HUD Blueprint (since you have it as target). But this doesn’t have your BPI interface GetByte function on it. You were suppose to target your BP\_SaveGame blueprint, but you can only do that after you’ve created the GameSave object. I’ve provided a sample of retrieving data from the GameMode blueprint using the interface class. This is what I do for global variables as well.

> **[BPI\_Test6](https://www.mediafire.com/file/a5u9s58nobm035m/BPI_Test6.rar/file)**
>
> MediaFire is a simple to use free service that lets you put all your photos, documents, music, and video in a single place so you can access them anywhere and share them everywhere.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4071fa6e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4071fa6e1](https://forums.unrealengine.com/u/anonymous_user_4071fa6e1)\
**Post date:** [September 23, 2014, 8:10am UTC](https://forums.unrealengine.com/t/sharing-variables-between-blueprints-via-interfaces/293963/7 "2014-09-23T08:10:37Z")

</div>

Thanks Peter, I appreciate the help.

_“You are trying to get the Byte from the HUD Blueprint (since you have it as target). But this doesn’t have your BPI interface GetByte function on it.”_

Ahh, silly mistake! Makes total sense when you point it out.

_“You were suppose to target your BP\_SaveGame blueprint, but you can only do that after you’ve created the GameSave object.”_

Out of curiosity, I replaced your [GetGameMode] with a _mySaveGameObj_.  
Doesn’t creating an instance of the **BP\_SaveGame** _mySaveGameObj_ variable in my BP\_HUD constitute a ‘creation’ (instantiation for use)?

_“I’ve provided a sample of retrieving data from the GameMode blueprint using the interface class.”_

Many thanks!  
That helped my understanding.

---

<div class="post-metadata">

**Author:** ![PeterLNewton](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PeterLNewton](https://forums.unrealengine.com/u/PeterLNewton)\
**Post date:** [September 24, 2014, 3:21am UTC](https://forums.unrealengine.com/t/sharing-variables-between-blueprints-via-interfaces/293963/8 "2014-09-24T03:21:29Z")

</div>

To your question about SaveGame, yes. By using Create SaveGame Object node to instance your BP\_SaveGame variable, you create an object. From there you can interface.

PS  
No problem at all, Pardon the delay.

---

<div class="post-metadata">

**Author:** ![Grixis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Grixis](https://forums.unrealengine.com/u/Grixis)\
**Post date:** [September 24, 2014, 4:51am UTC](https://forums.unrealengine.com/t/sharing-variables-between-blueprints-via-interfaces/293963/9 "2014-09-24T04:51:44Z")

</div>

I have created everything very similar to this system and have looked over your example. For some reason my int variable is “not in scope” on my return node on my interface. The variable i am trying to pass is set to public. Do you have a good idea as to why this would be?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4071fa6e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4071fa6e1](https://forums.unrealengine.com/u/anonymous_user_4071fa6e1)\
**Post date:** [September 24, 2014, 7:39am UTC](https://forums.unrealengine.com/t/sharing-variables-between-blueprints-via-interfaces/293963/10 "2014-09-24T07:39:29Z")

</div>

Grixis, follow it through and test each step of your implementation as there is probably something missing, mis-connected or an incorrect type. If you still can’t find the error then post a simplified (stripped-down) screenshot of the components in question.  
_A picture says a thousand words!_

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4071fa6e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4071fa6e1](https://forums.unrealengine.com/u/anonymous_user_4071fa6e1)\
**Post date:** [September 24, 2014, 9:03am UTC](https://forums.unrealengine.com/t/sharing-variables-between-blueprints-via-interfaces/293963/11 "2014-09-24T09:03:04Z")

</div>

_“By using Create SaveGame Object node to instance your BP\_SaveGame variable, you create an object. From there you can interface.”_

That works perfectly!

I basically have:  
_Event Receive Draw HUD-\>CreateSaveGameObject[BP\_SaveGame]-\>GetByte()_

For performance reasons, should I set up some kind of branch so **CreateSaveGameObject** only gets called once by _Event Receive Draw HUD_ (or Event Tick) or does that already happen internally?

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [September 25, 2014, 3:43pm UTC](https://forums.unrealengine.com/t/sharing-variables-between-blueprints-via-interfaces/293963/12 "2014-09-25T15:43:42Z")

</div>

Emmm explain me why you getting HUD… where you are in the HUD, also Casting to MyHUD… yet using Interface?

1. You don’t need to get HUD if you already in HUD, just use function with Target set to “self”
2. You don’t need to use Interface if you casting, as most people you misunderstanding what Interface is for, it’s not made for communication, it’s made to relate unrelated classed which you can’t cast… yet you casting and using interface 😛 You can access functions and events of object by draging and droping object link

Watch my tutorial about basics of objects it might clean your head

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4071fa6e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4071fa6e1](https://forums.unrealengine.com/u/anonymous_user_4071fa6e1)\
**Post date:** [September 25, 2014, 4:45pm UTC](https://forums.unrealengine.com/t/sharing-variables-between-blueprints-via-interfaces/293963/13 "2014-09-25T16:45:18Z")

</div>

Thanks .

SilentX already clarified & resolved my problem but I’m still watching your vid for extra knownedge.  
Cheers!

I’ll try not to be distracted by the cats …or the horses! (48:35)

---

<div class="post-metadata">

**Author:** ![Grixis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Grixis](https://forums.unrealengine.com/u/Grixis)\
**Post date:** [October 6, 2014, 3:28am UTC](https://forums.unrealengine.com/t/sharing-variables-between-blueprints-via-interfaces/293963/14 "2014-10-06T03:28:28Z")

</div>

Thanks a lot. I have now recently figured out how to do this. I was missing the get all actors of class node. I thought you were to use a target blueprint and get the exact variable. If you find the time i have recently posted a few other questions if your bored.
