Upon Player Quiting Room They Rejoin

Hello,

I made a pause menu for my game and whenever I try to leave the room it puts me back in. I've used PhotonNetwork.Disconnect(); and PhotonNetwork.LeaveRoom(); but the player keeps rejoining the room he left. Any idea on how to fix this?
 
Also I am working on a script that displays a game over screen after all players die, how can I check how many players are currently alive? Can I do that or do I have to get the health of every player to check?
 
Have you found a solution to players rejoining the room upon disconnect? Also I have the game over screen working for 1 player but Im not sure how to subscribe to the death events of all players in the room.
 
Last edited:

Justin

Administrator
Staff member
That is more on the PUN side of things - you should post over on their forum to see if they can help.
 
The players rejoining or getting all the death events? Wouldn't that be more suited on here since you guys made the pun addon?
 
I mean like subscribing to the death events of all players. The solution above is just for subscribing to one. I'm trying to listen for the death events of all player in the scene. I'm not sure how to go about that.
 

Justin

Administrator
Staff member
There isn't a global death event but you could create one by subclassing the CharacterHealth component and then send a global event by overriding the Die method. Something like:

Code:
EventHandler.ExecuteEvent("OnCharacterDeath", gameObject);
 

Justin

Administrator
Staff member
When you subclass the CharacterHealth component you'd override the Die method to send the global event:

Code:
public override void Die(Vector3 position, Vector3 force, GameObject attacker)
{
EventHandler.ExecuteEvent("OnCharacterDeath", gameObject);
}
From here you can register your own script for that death event:

Code:
EventHander.RegisterEvent<GameObject>("OnCharacterDeath", OnDeath);
 
Top