So I was wondering if there was a way to give or get a unique ID to/from all the players connected to the server.
I have this: (Concept)
From what I understand though, “Player Index” only works with LOCAL multiplayer, and that is not my intention.
So I was wondering if there was a way to get some sort of netID? Or something unique to the player when they connect? Or if I could create one in the construction of a player?
Hi, yes gamemode has a gamestate that has an array of all the players gamestate connected to server. So you need to get the GameMode -> getGameState -> PlayerArray-> PlayerId. I think GameMode only exist on the server so be careful when you try to access it.
Thank you, that’s great. Just what I was looking for really. Is there an event that happens when a new player is added to the PlayerArray? So I could put some of my own logic into it when that happens?
Well I thought I had it, but all clients and the server is returning their playerID as 0. Then I get an error “Error Accessed None ‘PlayerState’ from node New Event Dispatcher 0 in blueprint FirstPersonCharacter” so it’s receiving null for the playerstate?
You could assign a custom player ID whenever a new player joins. Player joins can be detected in the game mode blueprint server-side using a Event Post Login. It would look like this in your game mode blueprint:
In this case my default controller class is ExampleController and I have given it a replicated int variable PlayerID.