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 player number/index


I have been struggling to make a blueprint graph which could let me access the player's number in a multiplayer LAN RTS game. What I am basically aiming for is a functionality making the actors distinguish which actions are done by which players. For example, a red actor should only listen to a Move Command given by Player 2 and Attack Command given by Player 3, whereas a green actor should only listen to Move Commands from Player 3 and Attack Commands from Player 1. What is the easiest way for the actors' BPs to properly execute such idea?

As I haven't managed to find a straightforward node of doing that I thought of some workarounds which do not work unfortunately.

One supposed solution I tried was to get the PlayerID with PlayerState on EventPostLogin in the GameMode BP and as each player that joins the server gets an ID=ID of previous player +1, I tweaked those values to get the players' numbers. It somehow did not work and maybe that is a good thing since the ID method is not very reliable.

Any other ideas?

Product Version: Not Selected
more ▼

asked Feb 10 '15 at 12:34 AM in Blueprint Scripting

avatar image

51 16 21 25

avatar image Mariyan Sep 21 '15 at 11:23 PM

Hi, I have the same issue. Do you have any solution about that? Here is my post for my exact problem: https://forums.unrealengine.com/showthread.php?84585-Can-t-make-players-to-act-in-order-Turn-Based-Multiplayer If you managed to handle it, please share some info :).


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

2 answers: sort voted first

Identify player by PlayerControllers

more ▼

answered Sep 22 '15 at 12:13 AM

avatar image

37.3k 936 172 1116

avatar image Mariyan Sep 22 '15 at 08:18 AM

Hey Shadowriver, thanks for you answer, but can you explain with more details, please ? Do you mean, that every player that log in have to take different controller, and how they should be assigned?

avatar image Shadowriver Sep 22 '15 at 03:19 PM

No, they will have same PlayerController class, but spawned objects of that class are unique and you can use to identify invidual players. Objects (blue links and pins) are really memory pointers, they contain memory address that points to data of object, if you compare the two (with "==" node) you check if they point to same address, if they does it means you dealing with same object. So you simply check if PlayerController that issue order is the same PlayerController (that you hold in some varable) that have permission in specific unit, simple as that. In you PlayerController if you want you can generate unique id too.

You might seem player id used in engine function, but if you look on code of those functions you will see, it's just PlayerController pick from found in iterator (which assuming it is used for id, it means it always stacks PlayerController on top of another), 1st, 2nd or 6th found, it's not something assigned direcly


avatar image Mariyan Sep 22 '15 at 10:55 PM

Hi, again. Just to clarify I'm 3D artist and i work with BP only :). Btw i can't open that page at github(error 404). I will show you what i made for simple test in Player Controller class BP and maybe in this way you can help me easier. When a button is pushed in Widget BP i call an event (Next Player) at Player Controller BP, you can see the rest in the screenshot. "Set variable" works only separately for each player, although it's replicated!alt text

avatar image Shadowriver Sep 23 '15 at 08:04 PM

Assign IDs in GameMode on Post Login even, it will have PlayerController argument of player that, just cast it to you PlayerController class and set id varable or call some function that will assign it.

And again you don't need IDs just compare PlayerController variables, in unit make a variable which contain PlayerController that owns unit and when you issue order with some function, make argument there of PlayerController that issues order and compere PlayerController from argument and PlayerController of owner variable, if it's the same then you do the order, simple as that. UE4 don't have IDs because this is how engine expect you to check what player does what.

And don't excuse yourself that you are 3D artist :p i think you should able to understand what i said.

avatar image Mariyan Sep 26 '15 at 06:22 PM

Thank you for the help Shadowriver, much appreciated. My biggest mistake was that i understood one basic logic of the engine in wrong way. I made it, and it's working :).

avatar image mightyenigma Jan 22 '18 at 05:49 PM

Can't we just use the Get Player ID node? Or is that not what I think it is?

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

what you should do, I believe, is on gamemode -> event post login, create a global variable that increases every time a player logs in.. then insert this id to the playercontroller (Event post login has a controller variable, drag it and set player controller id).. then set this 'global variable' to the player.. so every time you use "get player controller", instead of 0 you will use the global variable stored (as identifier) in the player.

more ▼

answered Mar 08 '18 at 09:55 PM

avatar image

1 3 5

(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