How would I go about getting a specific player? I’m creating a multiplayer game and I am setting up the HUD to display lives of both players, but I don’t Player 1’s lives being shown where Player 2’s should be. Any ideas?
I know there’s a way to do this cleanly by getting the proper player index and comparing them, but honestly I’ve yet to figure that out. A work around would be to have the game assign each player to a “team” and store that on the player as an enum. Even as a 2 person game you could make an enum as “Team 1” and “Team 2” then have it assign the first person entering the game as “Team 1” and the second as “Team 2”. Then, you can just run a check on the character using the logic “if my Team == Team 1 then display Team 2”. Bit of a work around but could easily be implemented and should do what you need it too.
Hope this helps.
Ah ok so basically what I did was when the first player connects, I inserted them into an array of PlayerControllers (since all players get a controller), and array index 0 is player 1, index 1 is player 2. The spawnpoints on the map are labeled “Spawnpoint1” and “Spawnpoint2” and inserted those into a spawnpoints array in order, and once I spawned in a pawn at the spawn locations I inserted it into a third array. All 3 are shared to client so that I can properly use it for the HUD.
Though this seems like an incredibly sloppy way of doing that. I’m not sure if there’s a better way of doing it.