# Problem with casting

**URL:** <https://forums.unrealengine.com/t/problem-with-casting/437651>\
**Category:** Editor Scripting\
**Tags:** reference, casting, cast-failed, unreal-engine, question, Blueprint\
**Created:** [November 15, 2018, 1:18am UTC](https://forums.unrealengine.com/t/problem-with-casting/437651 "2018-11-15T01:18:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Voyager\_871](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Voyager\_871](https://forums.unrealengine.com/u/Voyager_871)\
**Post date:** [November 15, 2018, 1:18am UTC](https://forums.unrealengine.com/t/problem-with-casting/437651/1 "2018-11-15T01:18:57Z")

</div>

I do not understand why this is not working as it should. I am trying to create a jump pick up so whenever the player (which is a vehicle pawn/Sedan blueprint) runs over said pick up they obtain the ability to jump permanently. I am having a problem with casting the USB pick up blueprint to the Sedan blueprint. IMG\_A is the Sedan blueprint. If integer Pickedup (part of the cast) is more than or equal to 1 the branch will carry out the process.

In IMG\_B Pickedup IS set to one. I did a test in which if Pickedup was 1 a text would print. When I run over the pick up in game, the text appears clarifying that the integer is set to one but the jumping does not work.

My question here is why isn’t the Sedan blueprint not recognizing that Pickedup has been set to one but the USB blueprint does?? WITHOUT the cast, the jump function works PERFECTLY FINE. With the cast it does not. Is my object wild card wrong? (I am a bit confused when it comes to the referencing of things)

---

<div class="post-metadata">

**Author:** ![mightyenigma](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mightyenigma](https://forums.unrealengine.com/u/mightyenigma)\
**Post date:** [November 15, 2018, 2:30am UTC](https://forums.unrealengine.com/t/problem-with-casting/437651/2 "2018-11-15T02:30:10Z")

</div>

Do both the USB and the sedan have a Jump enabled variable? Casting doesnt give variables it just tells the blueprint to treat that actor as that class. If the actor is not a child or parent of that class type then the cast will fail.

---

<div class="post-metadata">

**Author:** ![Voyager\_871](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Voyager\_871](https://forums.unrealengine.com/u/Voyager_871)\
**Post date:** [November 15, 2018, 2:00pm UTC](https://forums.unrealengine.com/t/problem-with-casting/437651/3 "2018-11-15T14:00:52Z")

</div>

Sedan is the only one with a jump variable. If I Set the jump inside the USB, then sedan will refuse to jump with a simple press. I really do not understand how to create a simple power up that will last permanently.

---

<div class="post-metadata">

**Author:** ![Voyager\_871](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Voyager\_871](https://forums.unrealengine.com/u/Voyager_871)\
**Post date:** [November 15, 2018, 2:18pm UTC](https://forums.unrealengine.com/t/problem-with-casting/437651/4 "2018-11-15T14:18:38Z")

</div>

I FIGURED IT OUT YES! I scratched the INT and set a Boolean called IsUSBPicked as untrue as its default inside the sedan. In USB blueprint I did a cast to sedan and set Boolean as to true. THIS fixed my problem. I needed to set the variable inside the sedan rather than the USB blueprint. Also your comment gave me advice to further help me on this. Thank you so much for helping me!

---

<div class="post-metadata">

**Author:** ![mightyenigma](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mightyenigma](https://forums.unrealengine.com/u/mightyenigma)\
**Post date:** [November 15, 2018, 6:50pm UTC](https://forums.unrealengine.com/t/problem-with-casting/437651/5 "2018-11-15T18:50:02Z")

</div>

They both need to have a way to check if they have jump enabled. You can do that by having them both be child classes of a class that has that variable or you can give each their own (but you’ll have to cast and check both classes if you do that).

---

<div class="post-metadata">

**Author:** ![mightyenigma](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mightyenigma](https://forums.unrealengine.com/u/mightyenigma)\
**Post date:** [November 15, 2018, 6:50pm UTC](https://forums.unrealengine.com/t/problem-with-casting/437651/6 "2018-11-15T18:50:11Z")

</div>

You’re welcome.
