# How to get an APlayerController or camera on a server in C++.

**URL:** <https://forums.unrealengine.com/t/how-to-get-an-aplayercontroller-or-camera-on-a-server-in-c/2267587>\
**Category:** Multiplayer & Networking\
**Tags:** unreal-engine, question, CPP\
**Created:** [January 9, 2025, 10:30am UTC](https://forums.unrealengine.com/t/how-to-get-an-aplayercontroller-or-camera-on-a-server-in-c/2267587 "2025-01-09T10:30:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Babush61](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Babush61](https://forums.unrealengine.com/u/Babush61)\
**Post date:** [January 9, 2025, 10:30am UTC](https://forums.unrealengine.com/t/how-to-get-an-aplayercontroller-or-camera-on-a-server-in-c/2267587/1 "2025-01-09T10:30:21Z")

</div>

Hi. I am using APlayerController to get APlayerCameraManager to get camera coordinates (for LineTraceSingleByChannel).

If I use on the server

> GameplayStatics::GetPlayerController(this, 0)

then I only get the APlayerController for the first player.

How to get the ID for the APlayerController ? Or is there another way to get a specific APlayerController inside APawn ? Or another way to get the current camera coordinates of a specific APawn.

---

<div class="post-metadata">

**Author:** ![Yanard](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Yanard](https://forums.unrealengine.com/u/Yanard)\
**Post date:** [January 10, 2025, 12:38am UTC](https://forums.unrealengine.com/t/how-to-get-an-aplayercontroller-or-camera-on-a-server-in-c/2267587/2 "2025-01-10T00:38:37Z")

</div>

I’m not so experienced, but answer may be the trying to solve the problem from different perspective. Instead of directly trying to find the player:

- Can you select the player with line-tracing from some object?
- Can you get all players in the game then choose one?
- Maybe you can access via some outer?
- If you doing some editor code, it can be also good idea to send line-trace by editor whenever you click on the character u want to choose.

Based on the ID solution, I think retrieve all players then using array can work. I remember there were such method.
