My game was running fine with Netcode 1.0.2, but after I upgraded to 1.1.0 some issues started to occur. There is a short example of code that works fine in 1.0.2:
public override void OnNetworkSpawn()
{
if (!IsOwner) //called on client
{
//called on client right after spawning on 1.0.2 (never called on 1.1.0)
networkInit.OnValueChanged += UpdateBulletInit;
}
else //called on server/owner
{
//NetworkVariable value changed in server,
//makes OnValueChanged being called instantly on client
networkInit.Value = new BulletNetworkInit(){ _initialForce = 1, };
}
}
If spawned on server, the NetworkVariable immediately has its value changed (initialized).
If the Bullet was spawned on client, it would listen to every change of its NetworkVariable value on server.
This works fine in 1.0.2 in the way that client always get OnValueChanged called right after its spawn and everything is initialized correctly on client-side.
But after upgrading to Netcode 1.1.0 the OnValueChanged event is not beign called on client.
Instead, I had to call the initialization method directly doing something like:
public override void OnNetworkSpawn()
{
if (!IsOwner) //called on client
{
//call the initialization manually
UpdateBulletInit(networkInit.Value, networkInit.Value);
}
else //called on server/owner
{
//NetworkVariable value changed in server,
//makes OnValueChanged being called instantly on client
networkInit.Value = new BulletNetworkInit(){ _initialForce = 1, };
}
}
I don’t know what is the best approach, but everything was working fine before. I’m afraid there’s more changes to be made in the project to suit this new Netcode version.
I’m going back to 1.0.2 for now, but I appreciate any feedback or tips regarding this issue.