# \[Solved\]Struggling to Cast from a actor.

**URL:** <https://forums.unrealengine.com/t/solved-struggling-to-cast-from-a-actor/1808560>\
**Category:** Programming & Scripting\
**Tags:** casting, unreal-engine, failed, Blueprint\
**Created:** [April 17, 2024, 7:38pm UTC](https://forums.unrealengine.com/t/solved-struggling-to-cast-from-a-actor/1808560 "2024-04-17T19:38:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tacagaita](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tacagaita](https://forums.unrealengine.com/u/Tacagaita)\
**Post date:** [April 17, 2024, 7:38pm UTC](https://forums.unrealengine.com/t/solved-struggling-to-cast-from-a-actor/1808560/1 "2024-04-17T19:38:05Z")

</div>

From a character, I am having difficulty accessing the content of a text-type variable that is in an actor. I can’t cast the actor that is the parent of the variable.

 ![castproblem 01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/b/d/6bddda05329eaea88b63637701eb9bf292d4f51b.png)

On this BP\_TestCast i create and set the variable.

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/e/3/9e358b1d8fcf2a2d5782eb58d84f364271c5dcf3.png)

I’m not even getting a compilation error.

Thanks.

---

<div class="post-metadata">

**Author:** ![Wildlight03](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wildlight03](https://forums.unrealengine.com/u/Wildlight03)\
**Post date:** [April 17, 2024, 7:45pm UTC](https://forums.unrealengine.com/t/solved-struggling-to-cast-from-a-actor/1808560/2 "2024-04-17T19:45:11Z")

</div>

How / where are you setting the “Actor Variable”?

---

<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:** [April 17, 2024, 7:48pm UTC](https://forums.unrealengine.com/t/solved-struggling-to-cast-from-a-actor/1808560/3 "2024-04-17T19:48:40Z")

</div>

Creating an `Actor Variable` does not automagically create an actor instance 😇 That variable is just a reference that could point to **an** actor of that type - think of that variable as of an actor’s address. Where is the actor, though? How did it make it into the game? Which actor instance in particular do you mean? What if there’s 12 of them? How do you want to choose which one?

Consider spending some time with this:

> **[Blueprint Communication | Course](https://dev.epicgames.com/community/learning/courses/LWv/unreal-engine-blueprint-communication/ypKl/unreal-engine-blueprint-communication-overview)**
>
> In this course from the Epic Online Learning Team, create more efficient projects by dividing and organizing your Blueprints by functionality. Let’s exa...

* * *

As in the post above, you need to assign value to a variable for it to be valid. Once this is done, you may not need to cast at all…

---

<div class="post-metadata">

**Author:** ![Wildlight03](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wildlight03](https://forums.unrealengine.com/u/Wildlight03)\
**Post date:** [April 17, 2024, 7:53pm UTC](https://forums.unrealengine.com/t/solved-struggling-to-cast-from-a-actor/1808560/4 "2024-04-17T19:53:47Z")

</div>

Everynone put it very well. To get you started you could use the node “get actor of class” and set it to your BP\_TestCast to retrieve the instance and use the return to set “Actor Variable”… Then your cast should work.

Edit actually this is wrong, you wouldnt need to cast if you get the exact class…

---

<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:** [April 17, 2024, 8:02pm UTC](https://forums.unrealengine.com/t/solved-struggling-to-cast-from-a-actor/1808560/5 "2024-04-17T20:02:46Z")

</div>

> [@Wildlight03](#):
>
> get actor of class

Already returns the correct type, actually - no need to cast. But yeah, if there’s ever one instance **ever** , and you can’t be bothered / just experimenting, it’d work. But learning communication is the number 1 thing to learn. After all, coding is just moving data from one place to another. 🤷

* * *

I’ve always been saying it’s not the casting that is the problem - it’s obtaining the reference.

---

<div class="post-metadata">

**Author:** ![Wildlight03](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wildlight03](https://forums.unrealengine.com/u/Wildlight03)\
**Post date:** [April 17, 2024, 8:04pm UTC](https://forums.unrealengine.com/t/solved-struggling-to-cast-from-a-actor/1808560/6 "2024-04-17T20:04:37Z")

</div>

yeah i just caught that, i was trying to use something simple to illustrate the idea.

---

<div class="post-metadata">

**Author:** ![Tacagaita](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tacagaita](https://forums.unrealengine.com/u/Tacagaita)\
**Post date:** [April 17, 2024, 8:22pm UTC](https://forums.unrealengine.com/t/solved-struggling-to-cast-from-a-actor/1808560/7 "2024-04-17T20:22:06Z")

</div>

Thanks for the answer and for linking this material, it will help a lot. I’m new at unreal and the forum, do i need to close the post and tag a solution?

---

<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:** [April 17, 2024, 8:25pm UTC](https://forums.unrealengine.com/t/solved-struggling-to-cast-from-a-actor/1808560/8 "2024-04-17T20:25:23Z")

</div>

> [@Tacagaita](#):
>
> do i need to close the post and tag a solution?

That is up to you. Once you figure out what was needed, you can post a solution yourself and accept that! In case you still struggle and things are unclear after the course, see if you can answer the questions mentioned in the [post above](https://forums.unrealengine.com/t/solved-struggling-to-cast-from-a-actor/1808560/3). Sometimes seeing a clear example helps a lot - but to provide a tangible one, we’d need to know more about how things are set up on your end.
