# Get Access to Pawn Variables from an Actor object

**URL:** <https://forums.unrealengine.com/t/get-access-to-pawn-variables-from-an-actor-object/369505>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [September 6, 2016, 1:30am UTC](https://forums.unrealengine.com/t/get-access-to-pawn-variables-from-an-actor-object/369505 "2016-09-06T01:30:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![primacy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@primacy](https://forums.unrealengine.com/u/primacy)\
**Post date:** [September 6, 2016, 1:30am UTC](https://forums.unrealengine.com/t/get-access-to-pawn-variables-from-an-actor-object/369505/1 "2016-09-06T01:30:07Z")

</div>

I am trying to get access to my player pawn from an actor. I am not sure what to do. Please help. thanks.

---

<div class="post-metadata">

**Author:** ![MosesFlava](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MosesFlava](https://forums.unrealengine.com/u/MosesFlava)\
**Post date:** [September 6, 2016, 1:48am UTC](https://forums.unrealengine.com/t/get-access-to-pawn-variables-from-an-actor-object/369505/2 "2016-09-06T01:48:19Z")

</div>

You have to cast from the Actor to your pawn class.

```
void YourClass::OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	if ((OtherActor != this))
	{
      AYourPawnClass* tempPawn = Cast<AYourPawnClass>(OtherActor);
       if(tempPawn)
        {
           tempPawn->VariableYouWantToAccess = 10;
        }
     }
}

```

My apologies if I’ve misunderstood the question. if you’re interested in an actor like a projectile that has been called to be spawn by the owning pawn. GetInstigator may be a solution or custom collision channels

---

<div class="post-metadata">

**Author:** ![primacy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@primacy](https://forums.unrealengine.com/u/primacy)\
**Post date:** [September 6, 2016, 5:31am UTC](https://forums.unrealengine.com/t/get-access-to-pawn-variables-from-an-actor-object/369505/3 "2016-09-06T05:31:53Z")

</div>

Yup yup, I figured it out earlier but forgot to comment. I used the following lines of code`enter code here

```
    for (FConstPawnIterator Iterator = GetWorld()->GetPawnIterator(); Iterator; ++Iterator)
   {  
        if (Iterator->Get()->GetName() == "VR_PlayerChaperone_0")
        {
            auto i = Cast<AVR_PlayerChaperone>(Iterator->Get());
            if (i->arrow)
                i->arrow->current_arrow_state = AProjectileArrow::AIM;

        }
    }
```
