Should I check PhotonNetwork.CountOfPlayer in an Update function to see if the opponent has left?

Hi,
I have a 2 players game going, I am now wondering and trying to see how to best deal with disconnects (may them be intentional - there are disconnect buttons - or accidental (app quit) ... ?

i see there is the PhotonNetwork.CountOfPlayer value.... is it bad idea to check it regularly inside an update function, on both side (master and invited player), and if it goes under 2, i disconnect also the one left alone in the room ?

thank you so much

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @suhailhassan,

    Thank you for choosing Photon!

    There are callbacks for almost anything.
    See C# Callbacks.

    When a remote player leaves the room, OnPlayerLeftRoom callback is triggered.

    PhotonNetwork.CountOfPlayers is an application statistic that should not be accessible when joined to a room.
    Read more here.

    I highly recommend you start learning PUN by completing PUN Basics Tutorial.
  • thank a lot , sorry again for the stupid question
    i was too focused on finalzing the game that i didnt take enough time to read everything

    again, thank you, and thank you for your great support

    hope to finish soon and be able to buy the full payed version and plan !

    3 months ago i thought that online game would be impossible, and here i am having a functional online game !