Search Unity

Third Party Photon player object create twice when join game

Discussion in 'Multiplayer' started by rangolee302, May 5, 2021.

  1. rangolee302

    rangolee302

    Joined:
    Feb 1, 2018
    Posts:
    22
    (Probably there is a thread about this but i am still doing it)
    background :
    I am creating a game where players can join a lobby scene before they actually load the game scene. if all players is ready then the game scene will be loaded. I do this by creating a class LobbyPlayer for each player using PhotonNetwork.Instantiate which stores a bool isReady. it got sync by OnPhotonSerializeView so eveyone know other people's isReady.

    problem :

    A B
    create room -
    create LobbyPlayerA -
    - Join room
    create LobbyPlayerB create LobbyPlayerB
    create LobbyPlayerB -


    I am calling PhotonNetwork.Instantiate on Start. I have no idea whats going on...
    how do I suppose to keep track A on B's side and why LobbyPlayerB got Instantiate twice...
    Does anyone know?
     
    Last edited: May 5, 2021
  2. rangolee302

    rangolee302

    Joined:
    Feb 1, 2018
    Posts:
    22
    It got solve as soon as I post this... I found Start() called twice in B side and the reason is B has load lobby scene from custom room properties. then I load the scene again in OnJoinedRoom.
     
    tobiass likes this.