# How do I get the variable from another blueprint? What am I doing wrong?

**URL:** <https://forums.unrealengine.com/t/how-do-i-get-the-variable-from-another-blueprint-what-am-i-doing-wrong/489333>\
**Category:** Blueprint\
**Tags:** casting, cast-failed, cast-to, unreal-engine, question, Blueprint\
**Created:** [September 29, 2021, 12:44pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-variable-from-another-blueprint-what-am-i-doing-wrong/489333 "2021-09-29T12:44:05Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![kingdomheart661](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kingdomheart661](https://forums.unrealengine.com/u/kingdomheart661)\
**Post date:** [September 29, 2021, 12:44pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-variable-from-another-blueprint-what-am-i-doing-wrong/489333/1 "2021-09-29T12:44:05Z")

</div>

I’m creating a checkpoint thing, where when you touch an object it adds a point to a variable, and when you collide with the floor if checks the variable and depending on the value it teleports you to a different checkpoint. I attached photos of the blueprints. One of them is the blueprint that has the checkpoint variable and whenever you collide with the object it adds 1 point to the variable and the object teleports to the next checkpoint. The other blueprint is where I was the variable. The blueprint is supposed to use the checkpoint variable and add it to the Teleport variable (which is a new one) and then if the teleport variable equals 1 then the player is teleported to the checkpoint. The only problem is that the cast to thing doesn’t work. I think the problem is that I connected other actor to object, but I might be wrong.

 ![349569-landonblueprint.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/0/8/60884adbf793c35ec6b4b0e19b7a1da1bca4e6ef.png)

 ![349570-checkpointset.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/9/f/09fc5159fc15f0a8f6364e832ae9cb0a693ffb45.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [September 29, 2021, 12:53pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-variable-from-another-blueprint-what-am-i-doing-wrong/489333/2 "2021-09-29T12:53:52Z")

</div>

Is the first BP inside the player? It should be ok.

---

<div class="post-metadata">

**Author:** ![kingdomheart661](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kingdomheart661](https://forums.unrealengine.com/u/kingdomheart661)\
**Post date:** [September 29, 2021, 1:00pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-variable-from-another-blueprint-what-am-i-doing-wrong/489333/3 "2021-09-29T13:00:36Z")

</div>

Neither of them are in the player. The one that I want the variable in, is in the object that the player falls on and sends them back to the checkpoint. The one that sets the checkpoint variable is in the object that when the player collides with it, it adds a point to the object. Neither of the blueprints are in the player.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [September 29, 2021, 1:04pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-variable-from-another-blueprint-what-am-i-doing-wrong/489333/4 "2021-09-29T13:04:15Z")

</div>

If the player is falling on the chair, and the chair has the code and collision box, then the chair needs to check if the other actor is the player, not itself 🙂

---

<div class="post-metadata">

**Author:** ![kingdomheart661](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kingdomheart661](https://forums.unrealengine.com/u/kingdomheart661)\
**Post date:** [September 29, 2021, 1:09pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-variable-from-another-blueprint-what-am-i-doing-wrong/489333/5 "2021-09-29T13:09:07Z")

</div>

You’re talking about the second image right? The one on the bottom? That’s the blueprint for the chair. I tried setting the other actor (from the On Component Begin Overlap (Box)) to get player pawn, but it didn’t work, it won’t attach to player pawn.

---

<div class="post-metadata">

**Author:** ![kingdomheart661](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kingdomheart661](https://forums.unrealengine.com/u/kingdomheart661)\
**Post date:** [September 29, 2021, 1:11pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-variable-from-another-blueprint-what-am-i-doing-wrong/489333/6 "2021-09-29T13:11:30Z")

</div>

The player falls on a platform and is teleported to a certain checkpoint depending on the variable value at the time. Whenever the player touches the chair, it adds a value to the variable (atleast it’s supposed to). For example, if the player touches the chair for the first time, the variable becomes 1 and whenever the player falls onto the platform they are teleported to checkpoint1, and if they touch the chair again then the variable becomes two and whenever the player falls onto the platform they are teleported to checkpoint2.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [September 29, 2021, 1:17pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-variable-from-another-blueprint-what-am-i-doing-wrong/489333/7 "2021-09-29T13:17:26Z")

</div>

Ok, if the bottom one is the chair, whenever something overlaps it ( it doesn’t check what ) it will add one to teleport.

The top BP, whatever it is, will check if the overlapping actor is a chair. If it is, it might teleport depending on the value of checkpoint + teleport.

---

<div class="post-metadata">

**Author:** ![kingdomheart661](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kingdomheart661](https://forums.unrealengine.com/u/kingdomheart661)\
**Post date:** [September 29, 2021, 1:20pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-variable-from-another-blueprint-what-am-i-doing-wrong/489333/8 "2021-09-29T13:20:59Z")

</div>

For the chair, it’s fine if it adds a value if anything overlaps it since there only thing thats going to be able to overlap it is the player, but with the the top BP how do I make it check if the overlapping actor is a player and not a chair?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [September 29, 2021, 1:23pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-variable-from-another-blueprint-what-am-i-doing-wrong/489333/9 "2021-09-29T13:23:04Z")

</div>

Instead of casting to a chair, cast to the pawn:

![349594-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/e/2/ce2e6539b667d3ddee136715ba9eb17ca33d0b21.jpeg)

That’s what the cast is doing, it’s verifying the identity of the other actor.

You could also cast to the player:

 ![349595-screenshot-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/d/1/8d14297e15ff437980ba4f75af0a51a2e936871f.jpeg)

( or 3rd person etc ).

---

<div class="post-metadata">

**Author:** ![kingdomheart661](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kingdomheart661](https://forums.unrealengine.com/u/kingdomheart661)\
**Post date:** [September 29, 2021, 1:27pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-variable-from-another-blueprint-what-am-i-doing-wrong/489333/10 "2021-09-29T13:27:40Z")

</div>

If I do that though, then how do I get the variable from the other blueprint?

---

<div class="post-metadata">

**Author:** ![kingdomheart661](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kingdomheart661](https://forums.unrealengine.com/u/kingdomheart661)\
**Post date:** [September 29, 2021, 1:29pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-variable-from-another-blueprint-what-am-i-doing-wrong/489333/11 "2021-09-29T13:29:07Z")

</div>

Saw your answer. Was wondering though, if I cast to the player or pawn, then how do I get the variable from another blueprint?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [September 29, 2021, 1:29pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-variable-from-another-blueprint-what-am-i-doing-wrong/489333/12 "2021-09-29T13:29:58Z")

</div>

You need a reference to the chair in that top blueprint:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/e/9/9e97c54fbb743ecee1b9d3e4cf30cabc8f5cb9ac.jpeg "HTF do I? Blueprint to Blueprint Communication") ](https://www.youtube.com/watch?v=6IOgkWv1lEY)

---

<div class="post-metadata">

**Author:** ![kingdomheart661](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kingdomheart661](https://forums.unrealengine.com/u/kingdomheart661)\
**Post date:** [September 29, 2021, 1:37pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-variable-from-another-blueprint-what-am-i-doing-wrong/489333/13 "2021-09-29T13:37:16Z")

</div>

In the video isn’t he just casting? I did that in the top blueprint. I had it cast to the chair blueprint, so I could get the variable from it. Also if I cast to the player like you said, do I attach anything to it?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [September 29, 2021, 1:44pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-variable-from-another-blueprint-what-am-i-doing-wrong/489333/14 "2021-09-29T13:44:24Z")

</div>

Ok, not a great example, he named it badly, try this:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/9/b/29ba4e8b53f40f6df9bda750e7b7fb5486fe7142.jpeg "Blueprint Quickshot: Blueprint Communication | 05 | v4.7 Tutorial Series | Unreal Engine") ](https://www.youtube.com/watch?v=-CybtvNa2Ng)

You can make a variable in the blueprint which points at the chair. Casting is not for communication.
