# What do I cast in the cast function?

**URL:** <https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880>\
**Category:** Blueprint\
**Tags:** casting, cast-to, unreal-engine, UE4, Blueprint, question\
**Created:** [April 13, 2015, 1:15pm UTC](https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880 "2015-04-13T13:15:03Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_5c86276a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_5c86276a](https://forums.unrealengine.com/u/anonymous_user_5c86276a)\
**Post date:** [April 13, 2015, 1:15pm UTC](https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880/1 "2015-04-13T13:15:03Z")

</div>

My problem seems to be quite a simple one,  
as my casts ALWAYS fail and I think its because I just dont really know what I am supposed to cast.

I am usually making a reference to self.

Example:

I want my weapon to start firing when the Action “InputActionFire” is called by the hero, and therefore I made a tick and then casted to the hero class ( self). After that I “got” the variable I set aside for that and checked it with a branch… the cast fails tho ☹

Thanks in advance

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_776011b61](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_776011b61](https://forums.unrealengine.com/u/anonymous_user_776011b61)\
**Post date:** [April 13, 2015, 1:19pm UTC](https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880/2 "2015-04-13T13:19:29Z")

</div>

So your pawn is casting to your pawn or did I miss understand you?

---

<div class="post-metadata">

**Author:** ![Jurif](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jurif](https://forums.unrealengine.com/u/Jurif)\
**Post date:** [April 13, 2015, 1:28pm UTC](https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880/3 "2015-04-13T13:28:12Z")

</div>

Well I’m not sure what your problem is but here are few examples of casting:

> **[getting varible information from another blueprint?](https://forums.unrealengine.com/questions/181768/getting-varible-information-from-another-blueprint.html)**
>
> Well you could create a variable for player controller , when you do the cast you could set this variable. Now you have access to all the content of the casted object. Here’s an example of casting a GameModeBlueprint to a CharacterBlueprint or any...

> **[How to cast to a blueprint?](https://forums.unrealengine.com/questions/193839/how-to-cast-to-a-blueprint.html)**
>
> Hello, I’ve been reading the documentation on blueprint communication and apparently in the latest version (4.7), this feature seems to no longer be present, and neither is the Target Blueprint variable. So how do I cast to a blueprint now? Or how...

> **[How to access lvl BP variable from a diffrent blueprint](https://forums.unrealengine.com/questions/204300/how-to-access-lvl-bp-variable-from-a-diffrent-blue.html)**
>
> hello, i have a variable named “Counter” in my lvl blueprint, its an integer and its start from 10 and decreases by time. rather than printing it i would like to draw text on screen via hud blueprint. i found couple of forum post but no luck....

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_776011b61](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_776011b61](https://forums.unrealengine.com/u/anonymous_user_776011b61)\
**Post date:** [April 13, 2015, 1:33pm UTC](https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880/4 "2015-04-13T13:33:57Z")

</div>

Howdy

WHen you cast, you cast to ANOTHER BP, not your own, as the Variable is already there.

Here is a quick example.

![38556-capture.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/6/6/b6610d1c7b924283e6cb1d2f4c79caef2965d4bc.jpeg)

BP1 - I made a Variable

![38557-capture.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/0/8/608c6c5edadc2f879227e15b4cf5c7ef3687333e.jpeg)

If I Want it, just drag it out.

![38558-capture.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/6/2/f622265372eac5bc7552602f033519ebe8d3d797.jpeg)

In BP2, if I need it I cast.

 ![38559-capture.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/c/5/cc56b41a2a6b0c34ceed80aacc76481bcb1b64f1.jpeg)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_5c86276a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_5c86276a](https://forums.unrealengine.com/u/anonymous_user_5c86276a)\
**Post date:** [April 13, 2015, 1:47pm UTC](https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880/5 "2015-04-13T13:47:40Z")

</div>

works thanks so much yea I am still a started and realised that making EVERYTHING in the Hero class is not very smart ^^ you’re my saviour

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_24db280b1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_24db280b1](https://forums.unrealengine.com/u/anonymous_user_24db280b1)\
**Post date:** [April 14, 2017, 1:14pm UTC](https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880/6 "2017-04-14T13:14:52Z")

</div>

If I could find one ■■■■■■■ decent explanation of casting I would have figured this out about a month ago. For one thing whatever your saying doesn’t work. The array goes somewhere, then you have a node out of that into “”. Well how do I even get that. How do I get from out actors to ? I’m becoming more and more convinced they make this hard on purpose so no one will compete with unreal tournament.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_64c8b70d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_64c8b70d](https://forums.unrealengine.com/u/anonymous_user_64c8b70d)\
**Post date:** [July 26, 2018, 5:33am UTC](https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880/7 "2018-07-26T05:33:12Z")

</div>

when I do that it comes up with this:  
(The current value of the ’ Array ’ pin is invalid: Array inputs (like ‘Target Array’) must have an input wired into them (try connecting a MakeArray node).)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_64c8b70d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_64c8b70d](https://forums.unrealengine.com/u/anonymous_user_64c8b70d)\
**Post date:** [July 26, 2018, 12:23pm UTC](https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880/8 "2018-07-26T12:23:47Z")

</div>

when I do that it comes up with this (The current value of the ’ Array ’ pin is invalid: Array inputs (like ‘Target Array’) must have an input wired into them (try connecting a MakeArray node).)please help

---

<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:** [July 26, 2018, 2:32pm UTC](https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880/9 "2018-07-26T14:32:13Z")

</div>

post a screen shot of what you are talking about

---

<div class="post-metadata">

**Author:** ![samohickey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@samohickey](https://forums.unrealengine.com/u/samohickey)\
**Post date:** [March 5, 2019, 4:07am UTC](https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880/10 "2019-03-05T04:07:15Z")

</div>

I think that this is the hardest concept to grasp, yet seems the most common sense, with oriented programming.

A lot of the struggles I have when I am trying to code on my own go back to casting. I know I need to cast to get a reference to another BP, I know that I can make a reference variable to call from once I have casted… But… Before you can truly cast… You need that ‘’ input taken care of.

Easy enough when it’s just ‘GetPlayerController’ or ‘GetPlayerCharacter’… But when you try to reference one of your custom objects… That’s where my brain shuts down.

, this helps me so much with so many situations. Thank you! Great post!

---

<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:** [March 5, 2019, 5:22am UTC](https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880/11 "2019-03-05T05:22:55Z")

</div>

For more in depth look at this subject check out the first video about casting and the 2nd last one about creating references I think it will help clear some stuff up if you are having any other troubles

Unreal Engine 4 Beginner Tutorials: [https://www.youtube.com/playlist?list=PLyu-W38DvZhqByAoeva1jewB5s78zQHIy](https://www.youtube.com/playlist?list=PLyu-W38DvZhqByAoeva1jewB5s78zQHIy)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 12, 2021, 9:35pm UTC](https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880/13 "2021-10-12T21:35:34Z")

</div>

> nobody explains this well […] So frustrating.

The only more frustrating scenario is folks refusing to go through elementary tutorials and docs:

 ![350258-screenshot-5.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/a/f/bafb1186f7ffe3c44faae5afe995de611557ad9f.jpeg)

If you want to directly refence something from the level in the player blueprint:

- create a reference variable of the appropriate type in the player
- flag the variable as Instance Editable
- point it to the desired instance

---

<div class="post-metadata">

**Author:** ![denickes](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@denickes](https://forums.unrealengine.com/u/denickes)\
**Post date:** [October 12, 2021, 11:51pm UTC](https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880/15 "2021-10-12T23:51:12Z")

</div>

You took my “nobody explains this well” as me saying nobody put the effort into explaining this well but thats not the case. Truth is it’s a difficult concept to explain well as is evidenced by how many posts there are with the same question saying they all did the research but still cant understand it. But yeah be frustrated with us, makes us feel all warm and fuzzy opening up to the community for help!

---

<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:** [October 13, 2021, 12:15pm UTC](https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880/16 "2021-10-13T12:15:24Z")

</div>

Try these videos I made going over the whole concept of casting. First video I believe in the Playlist and the one about reference is also useful for understanding the concept.

https://www.youtube.com/embed/videoseries?list=PLyu-W38DvZhqByAoeva1jewB5s78zQHIy&wmode=transparent&rel=0&autohide=1&showinfo=1&enablejsapi=1

---

<div class="post-metadata">

**Author:** ![JoshCulpArt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JoshCulpArt](https://forums.unrealengine.com/u/JoshCulpArt)\
**Post date:** [November 6, 2021, 5:32am UTC](https://forums.unrealengine.com/t/what-do-i-cast-in-the-cast-function/314880/17 "2021-11-06T05:32:16Z")

</div>

Just wanted to say your solution was exactly what I was looking for. Thanks!
