What is the correct way to get a unique player ID for each player across all clients?
I see there is GetPlayerControllerID and also there is a playerID inside of PlayerState
I’m a bit confused as to which one I’m suppose to use and more specifically how to use each one. I tried calling SetPlayerControllerID in PostLogin, passing in 1, 2, 3, etc… for each new client but then when I tried to call
GetPlayerControllerID it just kept returning -1. I didn’t have much luck figuring out how to set the playerID inside of PlayerState either. Can anyone give me some details on the correct way to handle this? I feel like it should be a pretty simple thing to do… Thanks!
Under Palyer Controller, Use Self → GetPlayerControllerID and that will return correct number.
Using only GetPlayerControllerID will return -1
Top be honest, I’ve never tired to set ID’s manually at runtime. I only did it when I used node CreatePlayer and then I have entered ID manually in input field.
The playerID (from playerState) is something which is (or should be) generated by your onlinesubsystem - this could be your uniqueID. the playerControllerID is in multiplayer 0 => Server, 1…n for every connected client (on the server). the client only has a reference to its own controller. from a controller - i guess you can get playerState and feed that into a find which goes through the playerArray from the gameState. That return INT should be your playerIndex in terms of getPlayerControler(THISNUMBERYOUARELOOKINGFOR)