Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Getting Local Player Index

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!

Product Version: Not Selected
more ▼

asked Dec 06 '14 at 10:00 PM in Blueprint Scripting

avatar image

10 1 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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.

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Kismet/UGameplayStatics/GetPlayerController/index.html https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/APlayerController/GetSplitscreenPlayerByIndex/index.html

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

more ▼

answered Dec 06 '14 at 10:14 PM

avatar image

35.8k 927 169 1105

(comments are locked)
10|2000 characters needed characters left
Viewable by all users


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.

alt text

Hope you can read my messy layout, I tried to fir everything on one screen :p 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!

untitled.jpg (98.9 kB)
more ▼

answered Jul 25 '16 at 06:33 AM

avatar image

102 18 20 24

avatar image Trauts123 Apr 20 '19 at 10:59 AM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question