# Getting Local Player Index

**URL:** <https://forums.unrealengine.com/t/getting-local-player-index/300811>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [December 6, 2014, 10:00pm UTC](https://forums.unrealengine.com/t/getting-local-player-index/300811 "2014-12-06T22:00:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_3c089cdf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_3c089cdf](https://forums.unrealengine.com/u/anonymous_user_3c089cdf)\
**Post date:** [December 6, 2014, 10:00pm UTC](https://forums.unrealengine.com/t/getting-local-player-index/300811/1 "2014-12-06T22:00:23Z")

</div>

I am building a simple local multiplayer game using Blueprints in which I am trying to identify which player has collided with an object. I want to know if it was player 1 or player 2. I know each player has a unique Player Index value but I cannot figure out how to access it. Any help would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [December 6, 2014, 10:14pm UTC](https://forums.unrealengine.com/t/getting-local-player-index/300811/2 "2014-12-06T22:14:14Z")

</div>

There no stored player index, if you look on source code of those functions (exposed to blueprint) that use player index as input you will see they all use get array of players or iterators and use inputted index to just pick array position.

> **[UGameplayStatics::GetPlayerController](https://docs.unrealengine.com/5.1/en-US/API/Runtime/Engine/Kismet/UGameplayStatics/GetPlayerController/)**
>
> Returns the player controller found while iterating through the local and available remote player controllers.

> **[APlayerController::GetSplitscreenPlayerByIndex](https://docs.unrealengine.com/5.1/en-US/API/Runtime/Engine/GameFramework/APlayerController/GetSplitscreenPlayerByIndex/)**
>
> Returns the PlayerState associated with the player at the specified index.

You need to create your own player ID system if you want, i don’t think it should be difficult with blueprints just assign IDs on adding and removing players of the game

---

<div class="post-metadata">

**Author:** ![TornadoStorm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TornadoStorm](https://forums.unrealengine.com/u/TornadoStorm)\
**Post date:** [July 25, 2016, 6:33am UTC](https://forums.unrealengine.com/t/getting-local-player-index/300811/3 "2016-07-25T06:33:29Z")

</div>

Hello,

After quite a while of experimenting and tampering with nodes, I figiured out a way in which you could easily assign an index to all local players which is equal to the player index.

 ![99884-untitled.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/5/0/350320b7f4dec3104b8fe21ed161eeab4043d972.jpeg)

Hope you can read my messy layout, I tried to fir everything on one screen 😛  
See, I created a variable called ‘Local ID’ and have made it Editable, so that, using a function called ‘Update Local Player IDs’, I can cast to all players with their corresponding Player Indexes, and then simply assign the equal value to their Local ID. It s best to call this function whenever a local player joins or leaves a game. If you want to be super safe you can simply call it on the tick event. I then linked every ‘Get Player Character’ node to the Local ID, and profit!

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Trauts123](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Trauts123](https://forums.unrealengine.com/u/Trauts123)\
**Post date:** [April 20, 2019, 10:59am UTC](https://forums.unrealengine.com/t/getting-local-player-index/300811/4 "2019-04-20T10:59:21Z")

</div>

Any chance you could make a little bit more of a in depth guide on how to do this please? Im pretty much a beginner and having a really hard time trying to set this up xD
