The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Player prefab suddenly disappears from the scene

2018-09-10 11:36:43

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.


[Deleted User]
2018-09-11 09:02:06

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.

2018-09-11 09:33:58

It gets destroyed: 2 player instances on the client and the other instance of player on the master client.

[Deleted User]
2018-09-11 10:14:14

Is the owner of the removed object still in the room? Any code snippets of the synchronization?

2018-09-11 13:55:21

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.

[Deleted User]
2018-09-11 14:06:25

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.

2018-09-11 14:28:00

I can give you Unity Teams access

[Deleted User]
2018-09-11 14:35:08

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.

2018-09-12 12:13:47

I sent you a private message with the repro project link. Also, thanks for help!

[Deleted User]
2018-09-13 09:57:22

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.

2018-10-01 04:10:02

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!

Back to top