# Trouble getting local player controller on clients?

**URL:** <https://forums.unrealengine.com/t/trouble-getting-local-player-controller-on-clients/143881>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [May 18, 2020, 6:08am UTC](https://forums.unrealengine.com/t/trouble-getting-local-player-controller-on-clients/143881 "2020-05-18T06:08:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![exxecutioner](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@exxecutioner](https://forums.unrealengine.com/u/exxecutioner)\
**Post date:** [May 18, 2020, 6:08am UTC](https://forums.unrealengine.com/t/trouble-getting-local-player-controller-on-clients/143881/1 "2020-05-18T06:08:22Z")

</div>

This is incredibly stupid but at the same time, I can’t figure it out. I know player controllers only exist on the client, but I don’t understand why I can’t get the controller on the clients themselves either. I have the following code in the BeingPlay() of my Character class :

myController = Cast\<AFPSGameController\>(GetController());

if (myController) {  
FString msg = “Controller fetched in " + GetName();  
UKismetSystemLibrary::PrintString(this, (TEXT(”%s"), \*msg));  
}

I would expect this code to print 1 line each on the instances. What I mean is if I start 4 instances of the game (1 server, 3 clients), I thought each client would be able to successfully get their own player controllers. So suppose Char\_1, Char\_2, Char\_3, and Char\_4 get spawned for server, client 1, client 2, and client 3 respsectively, Char\_1 would successfully fetch and print the message on server, Char\_2 would print the message on client 1, Char\_3 on client 2, Char\_4 on client 3.  
But the logs being printed look like this :

LogBlueprintUserMessages: [EBaseCharacter\_C\_1] Server: Controller fetched in EBaseCharacter\_C\_1  
LogBlueprintUserMessages: [EBaseCharacter\_C\_0] Client 3: Controller fetched in EBaseCharacter\_C\_0  
LogBlueprintUserMessages: [EBaseCharacter\_C\_0] Client 1: Controller fetched in EBaseCharacter\_C\_0  
LogBlueprintUserMessages: [EBaseCharacter\_C\_0] Client 2: Controller fetched in EBaseCharacter\_C\_0

Really sorry for being a noob but I’m having a tough time with this. Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![Jambax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jambax/32/904177_2.png) [@Jambax](https://forums.unrealengine.com/u/Jambax)\
**Post date:** [May 18, 2020, 8:14am UTC](https://forums.unrealengine.com/t/trouble-getting-local-player-controller-on-clients/143881/2 "2020-05-18T08:14:35Z")

</div>

This looks correct to me. Characters and Controllers will not share the same object names accross different instances of the running game so ID’ing the object by it’s name isn’t a reliable way to identify it.

E.g, The Server (assuming it’s a listen server in this case) will have four controllers - it will create it’s own controller first (suffix \_0) - then client controllers (suffix \_1 - \_3)

Clients will only ever have their own controller. Since it will be the first controller, they will all be suffixed with \_0. Characters may be received in any order, depending on which one replicates first.

---

<div class="post-metadata">

**Author:** ![exxecutioner](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@exxecutioner](https://forums.unrealengine.com/u/exxecutioner)\
**Post date:** [May 19, 2020, 1:26am UTC](https://forums.unrealengine.com/t/trouble-getting-local-player-controller-on-clients/143881/3 "2020-05-19T01:26:14Z")

</div>

@TheJamsh You’re right. Added a IsLocalController() check and got the same results. Thanks for the help!
