Objective: I want to get the NetworkLobbyPlayer instance BEFORE it’s destroyed so I can decide which player to remove from my lists and pull some info from it.
(I ORIGINALLY was using callbacks from the player script on client-side, but for non-graceful disconnects, the player can no longer send a Cmd because he’s, well, gone)
Steps:
-
So a client disconnects,
-
I catch it on my NetworkLobbyManager script with public override void OnServerDisconnect(NetworkConnection conn)
(^ This is the best override to catch it, right?) -
So I have a NetworkConnection callback… now what? For a direct connection, this probably helps me - but for matchMaker, it does’t really help much since it didn’t give me any info about the NetworkLobbyPlayer… or does it?
-
I get the IP address… eh.
-
connectionId… ooh, what can I do with this? I’m testing as I type this.
-
clientOwnedObjects… I thought I could get the player, but it’s null at this point.
-
hostId… not sure what to do with this.
-
lastError… would that reveal the player?
-
playerControllers… this is only local controllers right? Should always be 0 right?
-
…that’s all I can find. Maybe I can do Network.players[connectionId] or [hostId] or something to get the player? It’s all trial-and-error from here.
I’m testing things while waiting on a response, but if anyone could help me skip trial+error, I’d toss you an epic thanks ;D