# How to use mouse click to change current pawn under control?

**URL:** <https://forums.unrealengine.com/t/how-to-use-mouse-click-to-change-current-pawn-under-control/26607>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [April 6, 2015, 2:25pm UTC](https://forums.unrealengine.com/t/how-to-use-mouse-click-to-change-current-pawn-under-control/26607 "2015-04-06T14:25:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![anonymous\_user\_6d3a5d00](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6d3a5d00](https://forums.unrealengine.com/u/anonymous_user_6d3a5d00)\
**Post date:** [April 6, 2015, 4:10pm UTC](https://forums.unrealengine.com/t/how-to-use-mouse-click-to-change-current-pawn-under-control/26607/2 "2015-04-06T16:10:03Z")

</div>

You have to iterate through all of the pawns in the world, unfortunately. You can look for subclasses and there are ways to modify your iterator to find specific classes, but in code its the only way.

```auto

for (TActorIterator<AActor> ActrItr(GetWorld()); ActrItr; ++ActrItr)
{
      ActorNameString = ActrItr->GetName();
      if (ActorNameString == something)
      {
         ContainerForPawn = ActrItr;
      }
}

```

Obviously, it needs more logic than this to get to your final project, but the for loop iterator I provided is a basis for what you need. More info on actor iterators is here:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

---

_[View the full topic](https://forums.unrealengine.com/t/how-to-use-mouse-click-to-change-current-pawn-under-control/26607)._
