- Home /
Networking | Getting buffered other - previous spawned players
When all players are connected and server launches scene, everybody can see each other, everything works perfectly. This is what most tutorials are showing, everybody connects and server launches scene. But, when server and scene is already launched and player connects, he does not see previously connected players. Previously connected users see all newest connected player, but new player doesnt. If someone else joins, then again, he wont see anyone, previous player will see himself and newest member, but player who was joined at the start sees all 3.
Network.Instantiate is buffered, so problem should be with the way i spawn players. I've tested the spawning many ways and in countless combinations. Via Awake (spawn on new scene), as DontDestroyOnLoad, OnPlayerConnected, OnLevelWasLoaded and couple other ways. The way I set it up, theoretically result should have be the same (if taking stricly unity docs mentioned information), but at the end they all give somewhat different results. So after 2 days, today i kinda got out of ideas, and started to get into loop.
For now, im spawning the player in the new scene on Awake(), and transferring another GO from previous scene with DontDestroyOnLoad (for not disconnecting) as it is stable, and everything works perfectly, except my mentioned problem. I understand the problem is "with the way you spawn", so awake() solution shouldn't be really the one.
Thank you very much.
I have had my fair share of related problems. What I think is happening is that your game is being told to Instantiate the players when the game really isn't ready to(eg. when your players is being spawned just before you load your scene, then they will usually be destroyed).
Depending on how you have setup you scenes, players etc. Only when the scene is fully loaded should you Instantiate your players. Therefore I use PhotonNetwork.is$$anonymous$$essageQueueRunning = false(or you equivalent) to stop inco$$anonymous$$g network messages(messages telling me to Instantiate). And then only set it to true when your scene is fully loaded.
Answer by YoungDeveloper · Feb 13, 2014 at 01:40 PM
lmao, i just tried this 3 minutes ago and it worked. Of course now the problem is that i see all other players only where they were spawned, because thats the only buffered information. But if they start to walk to some location, clone will go to that new point.
So just for the record, in C#, instead of reactivating MessageQueueRunning and SetSendingEnabled in "LoadLevel" (like in this example http://docs.unity3d.com/Documentation/Components/net-NetworkLevelLoad.html), reactivate them only when actual scene is loaded, took me 4 days to get this.. god..
void OnLevelWasLoaded(int level) {
Network.isMessageQueueRunning = true;
Network.SetSendingEnabled(0, true);
///other stuff what you want to do, for example spawn player
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613133231im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Network.Instantiate and NetworkServer.Spawn not working 2 Answers
Network.Instantiate/Destroy vs Instantiate/Destroy on each client using [Command] and [ClientRpc] 1 Answer
Players Not Showing 0 Answers
Help me please with Unity Multiplayer 1 Answer
Problems with spawning items that the players can pick up - Unet 0 Answers