Thursday 24 April 2014

Manual vs Automation

I spent several hours trying to use what I was expecting to be better methods to control spawning character when the level changes in a network game.  I'm using the Photon Unity Networks (PUN) methods.

According to the following forum post the automated methods should handle pausing messages when the scene changes.

PhotonNetwork.automaticallySyncScene = true

As far as I can tell, they work but the trouble with automation is that it is only useful if the person designing the automation was thinking the same way as you are.  In this case, Exit Games were not.

I have a scene selection popup and a lobby scene before the level loads.

The server and the client can sit at that lobby and join the game when they are ready.

By manually controlling the network message flow I can allow the server and the client to join in any order.   If I use the automated methods the server must be in the game scene before any of the clients!

PhotonNetwork.SetSendingEnabled(0, false);
PhotonNetwork.isMessageQueueRunning = false;

Obviously I prefer my method.  I simple disable the messages before loading a level and start them again only when the scene has started and before the spawn message is sent.

The only reason I tried to change to the automated methods was because I was trying to get rid of some annoying PhotonNetworks warning and error log messages whenever I exit a scene.

OnDestroy for PhotonView View (0)1001 on CharacterPlaceholder(Clone)  but GO is still in instantiatedObjects. instantiationId: 1001. Use PhotonNetwork.Destroy().

Failed to 'network-remove' GameObject because it's null.

The automated methods did not fix those either!

Back to finding a fix for the errors!

No comments: