Duplicate Players Problem

Options
Hi, I'm new to Photon, but got it working in my project by using the Photon flight combat tutorial as basis for my implementation... (flight shooter)
All the basics work fine... spawn ships, join game, shoot various weapons at each other.... But I keep getting cloned copies of player in the score list. Say 2 players join. Bob and Jim. They shoot each other.. and after a short while, the player list now shows 2 bobs and 1 Jim. Neither has left the game or re-joined.
How is this possible, what might I be doing wrong ? something to do with re-spawn maybe ?
any ideas welcome.
Cheers

Comments

  • vadim
    Options
    How do you render player list? Log content of PhotonNetwork.playerList to make sure that Photon keeps that list up-to-date. If it's ok, something wrong with gui.
  • JonnyHilly
    edited June 2016
    Options
    Thanks for the reply Vadim, Well after adding lots of prints, and some crashy unity debugging. its only calling CreateLocalPlayer() once for each player (which does a PhotonNetwork.Instantiate() of player's ship) ...correctly. But when it calls it for the second player joining the game.... the photonNetwork.instantiate gets called twice, on the first player's machine, which is obviously wrong. It actually created 2 ships/players, one that works... and one that just sits there at its spawn location, doing nothing much....
    So.... Why / How can PhotonNetwork.Instantiate() execute once on one machine, and twice on another machine ?

    I'm not sure what I can do about this.... I can put in some check code, to check for instantiated duplicate ships... but if I delete one, how can I be sure its the right one.... and will this happen with weapons/bullets also ?

    update... ok so I tried that... code successfully detects duplicate ship and destroys it.... so there is correct number of ships in each player's game... but its the wrong ship... it destroys second shop that photon tried to create... but it needed to destroy the first on, so think this is unreliable / bad fix.

    could it be ship from a previous play.. not destroyed properly, being added by photon ?
    The duplicate ships have the same player name and owner ID

    any ideas ?
  • vadim
    Options
    Where do you call PhotonNetwork.Instantiate() ? For player's objects good practice is to do so in OnJoinedRoom(). This callback called once on every clients as soon as it joins a room. So there is no chances to get it called twice.
  • JonnyHilly
    Options
    its in the same place as the Photon 2 player ship demo... its exactly that same code as far as lobby and instantiating ships goes. I built on top of that, for my demo, just modifying controls, and weapons.