Search Unity

Third Party photon bugging out after a few battles

Discussion in 'Multiplayer' started by BigGameCompany, Apr 9, 2020.

  1. BigGameCompany

    BigGameCompany

    Joined:
    Sep 29, 2016
    Posts:
    112
    Hi all,

    I posted this over at the photon forums but they don't seem very active these days so I'm trying my luck here. Here the post anyway: https://forum.photonengine.com/disc...bject-always-create-a-fresh-instance/p1?new=1

    To summarise:

    I have a 2 player game. When 2 players enter the room, the room is set to closed and invisible. A new scene loads and the master client uses PhotonNetwork.Instantiate to make a bunch of scene objects at the start of the battle. These use OnPhotonSerializeView to sync things like health, mana etc. This all works fine and if the master client disconnects, the other player takes over ownership of the scene objects and continues running the game while the original master client reconnects. When the battle is over they both leave the room and go back to the matchmaking scene where they search for a new battle or create a new room if they can't find one.

    It's all working well except...

    About once in every 10-20 battles, it just completely breaks right from the start for the non-master client, with health and mana values jumping all over the place. The master client seems fine. In the OnPhotonSerializeView stream.IsWriting I can see normal looking values like

    health 3000
    health 3000
    health 2900

    but in the receiving section for the same photon view the values are wildly jumping up and down

    received health of 2165.25
    received health of 2165.25
    received health of 691.8351
    received health of 259.2783
    received health of 169.2783
    received health of 169.2783
    received health of 2105.25
    received health of 2105.25
    received health of 0
    received health of 0
    received health of 1.177621E-38
    received health of 1.177621E-38
    received health of 1.177621E-38
    received health of 1.177621E-38

    This is happening on a few different objects.

    I'm using PhotonNetwork.Time to start the battle at the same time for both players and I noticed that when the bug above occurs, I also get a negative value for PhotonNetwork.Time.

    Can anyone suggest some things to look into? I've spent a few days on this and I'm stumped.

    Thanks
     
    Last edited: Apr 12, 2020
  2. BigGameCompany

    BigGameCompany

    Joined:
    Sep 29, 2016
    Posts:
    112