How to properly use PlayerArray (add/remove players)?
So, i´m developing my first multiplayer game, i´m on the stage where I would like to create a menu where you can see blue team and red team , if you connect to my server, you can get the list of connected players. While doing some research, I found this thread:
...which basically says that GameState and PlayerState is already prepared to work on this feature.
Of course it didn´t work. Everytime I try to loop this array, it´s empty. So question is...
1) When my player connects to my server, how does the gameState knows that a player is connected?
2) How should I use the PlayerArray? Shoudl I add playerStates manually?
3) I can see this Player State has an ID, but this ID changes all the time, is not unique for the player, so what is the idea of this ID if it will not be reliable?
4) I see you have a "GetPlayerName" but there is no way to "SetPlayerName"... (I think this is a very old question nobody knows)
So in conclusion, if somebody could point me best way to achieve this, will be very welcome. Thanks!
asked Dec 19 '18 at 07:12 PM in Using UE4
1) The gamestate knows that a player has connected because the game mode tells it that a player has join I believe. You can hook into this event using the
2) As far as I remember, the playerstates are automatically added to the playerarray when a player joins a server. If it doesn't, you can do that yourself in the event I mentioned in 1. The way to interact with these would be to get a playerstate and then cast it to your playerstate class.
3) So this player ID does represent a unique number for a player. It can change based on which online subsystem you're using, but it will always be unique. From the documentation:
4) Playerstate does have a
answered Dec 19 '18 at 07:49 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here