Inconsistent spawning between editor and build client
I have a very frustrating issue where games hosted from the editor have different behavior than games hosted from the client.
For example I have a syncvar hook set up for on name changed:
public void OnNameChanged(string value) {
playerName = value;
gameObject.name = value;
nameMesh.text = value;
}
When I host a game via the editor and connect from a standalone client, the NameMesh is updated on all clients (including on the unity editor).
When I host a game via the standalone client, the NameMesh information is only updated on the stand alone client. I've tried instantiation and I get the exact same behavior.
The most annoying thing is when i use the inspector to view the game objects, the playerName variable which is being used is set to their expected values.
I am using Unity 5.5
Answer by Ralgarog · Jan 22, 2017 at 03:58 AM
I am not sure why the spawning was so inconsistant but my issue is that I was using syncvar hooks without setting the initial state in OnStartClient();