# I need to share a variable between 2 BP

**URL:** <https://forums.unrealengine.com/t/i-need-to-share-a-variable-between-2-bp/437924>\
**Category:** Blueprint\
**Tags:** share, unreal-engine, cast, question, Blueprint\
**Created:** [November 19, 2018, 4:22pm UTC](https://forums.unrealengine.com/t/i-need-to-share-a-variable-between-2-bp/437924 "2018-11-19T16:22:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MihailGor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MihailGor](https://forums.unrealengine.com/u/MihailGor)\
**Post date:** [November 19, 2018, 4:22pm UTC](https://forums.unrealengine.com/t/i-need-to-share-a-variable-between-2-bp/437924/1 "2018-11-19T16:22:18Z")

</div>

Hello! i need to share a “hit” variable between 2 BP. one of them is enemy, and second is weapon. to check this variable in second BP ( 2 screenshot). How to do it? i really dont understand how to cast between 2 BP ((( becaue get player character is not work…

 ![259852-скриншот-2018-11-19-191330.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/d/e/4debee1b168da0b3f7189d8e3f5f1ac737242c7e.png)

 ![259853-скриншот-2018-11-19-191325.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/b/4/1b4be83b0357fea47e625008dcd3d1399b1e82e5.png)

---

<div class="post-metadata">

**Author:** ![Nebula\_Games\_Inc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nebula\_Games\_Inc](https://forums.unrealengine.com/u/Nebula_Games_Inc)\
**Post date:** [November 19, 2018, 4:49pm UTC](https://forums.unrealengine.com/t/i-need-to-share-a-variable-between-2-bp/437924/2 "2018-11-19T16:49:03Z")

</div>

You need a reference to the Enemy BP from the weapon if you want to get a variable out of the enemy and modify it within the weapon. I am not really sure what exactly the logic is behind what you are doing but I am sure there is an easier way. I don’t even know what the second screen shot is supposed to be showing. A little more clarification would be helpful. Also this is the 3rd person BP and a “Pistol BP” which is the “enemy”?

---

<div class="post-metadata">

**Author:** ![MihailGor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MihailGor](https://forums.unrealengine.com/u/MihailGor)\
**Post date:** [November 19, 2018, 5:10pm UTC](https://forums.unrealengine.com/t/i-need-to-share-a-variable-between-2-bp/437924/3 "2018-11-19T17:10:11Z")

</div>

i made a reference variable, name “pistolhit” in pistol BP and reference it with enemy BP. from here i take a “hit” variable that was in enemyBP (1st screenshot). But its not work…

 ![259855-скриншот-2018-11-19-195219.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/0/5/c053a2c275c3948c0cce94f7e9472ae303fc7c24.png)

---

<div class="post-metadata">

**Author:** ![Nebula\_Games\_Inc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nebula\_Games\_Inc](https://forums.unrealengine.com/u/Nebula_Games_Inc)\
**Post date:** [November 19, 2018, 5:19pm UTC](https://forums.unrealengine.com/t/i-need-to-share-a-variable-between-2-bp/437924/4 "2018-11-19T17:19:48Z")

</div>

Not gonna lie, that is an extremely odd naming scheme. “Pistol Hit” is actually a reference to your 3rd person character enemy and the “Hit” variable is located in “3rd Person Character Enemy\_2”. So a couple things could be wrong with that reference you might not be referencing the exact 3rd person BP you think, the “enemy\_2” seems to suggest you have multiple similarly named BPs. Additionally where did you actually “create” the reference? You should have had a cast node or overlap or something to make that reference variable actually point to something. As it stands looks like you just hit the “variable +” button on the left side panel and created a variable with no actual reference to an in game object. You can’t make object references the way you would a boolean or integer variable.

---

<div class="post-metadata">

**Author:** ![MihailGor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MihailGor](https://forums.unrealengine.com/u/MihailGor)\
**Post date:** [November 19, 2018, 5:40pm UTC](https://forums.unrealengine.com/t/i-need-to-share-a-variable-between-2-bp/437924/5 "2018-11-19T17:40:26Z")

</div>

Thanks its work!!!

 ![259858-скриншот-2018-11-19-203932.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/0/e/f0ebb317f80ff74606cf1897c9778db1b9c87287.png)

---

<div class="post-metadata">

**Author:** ![Nebula\_Games\_Inc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nebula\_Games\_Inc](https://forums.unrealengine.com/u/Nebula_Games_Inc)\
**Post date:** [November 19, 2018, 5:46pm UTC](https://forums.unrealengine.com/t/i-need-to-share-a-variable-between-2-bp/437924/6 "2018-11-19T17:46:48Z")

</div>

Glad you figured it out.
