SyncVar
private SyncVar<int> mySync = new(2); //Now defaults to 2
private SyncVar<int> myOtherSync = new(5, ownerAuth:true); //Defaults to 5, and is owner auth
protected override void OnSpawned(bool asServer)
{
mySync.onChanged += OnMySyncChange;
if (asServer)
mySync.value = 420;
if (isOwner)
myOtherSync.value = 69;
}
private void OnMySyncChange(int newValue)
{
Debug.Log("SyncVar has changed to: " + newValue);
}Last updated