Player prefab suddenly disappears from the scene

Hello,
I am developing a coop fighting game and I have a problem with Photon integration.After I stopped synchronizing clients using photon transform view and photon animator view I made it synchronize inputs through RPC calls and serialize other variables. Now I have a better synchronization but after a while playing the player prefab suddenly disappears from the scene without any error or log message. Also, this doesn't happen in the editor and I don't have any PhotonNetwork.Destroy() called for the player in the project.

Comments

  • Hi @ovalmobile,

    this is odd. When saying, that 'the player prefab suddenly disappears', do you mean, that it is not visible / on the screen any longer or that the object gets completely destroyed? To check, if it gets destroyed, you can either take a look at the scene hierarchy in the Unity Editor or use the OnDestroy function and log something to the console. If the object doesn't get destroyed, check it's attached components to see if there is something wrong, for example if the position is wrong or if the renderer gets disabled somehow. If you can't find the reason, why this happens, some code of your synchronization might be helpful.
  • It gets destroyed: 2 player instances on the client and the other instance of player on the master client.
  • Is the owner of the removed object still in the room? Any code snippets of the synchronization?
  • It is still in the room, i get no disconnect message and the scene remains loaded. I can't figure out what code snippets would help you, the thing that makes this happen (I did a bunch of tests using elimination of the script parts and came to this conclusion) is that the networked script listens to an input manager script and synchronize the inputs through RPCs.
  • Can you show the code which you think is causing trouble?

    Is there any chance, that you can create a repro project for me or give me some instructions how I can reproduce this issue? I'm currently out of ideas what the problem is.
  • I can give you Unity Teams access
  • I would prefer a stripped-down repro project with a short instruction uploaded to Dropbox or Google Drive, if it's possible. If you do this, please don't forget to remove your AppId, especially if it is a paid one. If the repro project is not possible, please let me know.
  • I sent you a private message with the repro project link. Also, thanks for help!
  • Hi @ovalmobile,

    thank you for sharing this project with me. I have taken a look into it and found the issue. The reason is, that the client (standalone build) has a DisconnectByClientTimeout. You can check this yourself by adding the void OnConnectionFail(DisconnectCause cause) callback to the source code. This one is called, after something causes the connection to fail (after it has been established once). After recognizing this, I have taken a look at some stats and have seen, that in my case this client has 221,246 resends, which is definitely too much. I have also attached the PhotonStatsGui (a component which gives you a visual representation about certain network stats) and noticed, that you are sending way too much data.

    You can also take a look at the Dashboard and analyze your used AppId. On this page you can see multiple diagrams. One of them is showing the Msg/s per room max. While testing the game, this value literally exploded and raised up to nearly 4,000 which is too much for just two players.

    I would recommend you taking a look at the entire source code and check, where you can optimize sending messages. I would also recommend you taking a look at the Analyzing Disconnects documentation page, to read more about Timeout Disconnects.
  • this thread helped me greatly thank you. Using Photon Stats component, I found that I had many extra calls, fixed it, thus fixing the timeout. Thanks!