Search Unity

Host not syncing

Discussion in 'Multiplayer' started by metalkat, Feb 4, 2016.

  1. metalkat

    metalkat

    Joined:
    Feb 19, 2011
    Posts:
    38
    Lets keep it simple, the host is not getting new values, this also happens with syncLists
    any thoughts?

    Code (CSharp):
    1.  
    2.  
    3.         void Start() {
    4.             if(isLocalPlayer) {
    5.                 health = UnityEngine.Random.Range(10, 39);
    6.             } else {
    7.                //other stuff
    8.             }
    9.             UpdateHealthUI();
    10.         }
    11.  
    12.         [SyncVar(hook="OnHealthChange")]
    13.         public int health;
    14.  
    15.         public void OnHealthChange(int _health) {
    16.             health = _health;
    17.             UpdateHealthUI();
    18.         }
    19.  
    20.  




    Im doing a quite simple matchmaking just for testing, could this be the error?

    Code (CSharp):
    1.  
    2.         public IEnumerator LoadMatchMaker() {
    3.             int trys = 1;
    4.             while (trys < 4) {
    5.                 manager.matchMaker.ListMatches(0, 2000, "", manager.OnMatchList);
    6.                 yield return new WaitForSeconds(1f);
    7.                 trys++;
    8.                 if (manager.matches != null) {
    9.                     if (manager.matches.Count > 0) {
    10.                         foreach (var match in manager.matches) {
    11.                             manager.matchName = match.name;
    12.                             manager.matchSize = (uint)match.currentSize;
    13.                             manager.matchMaker.JoinMatch(match.networkId, "", manager.OnMatchJoined);
    14.                             Debugger.Manager.Log("Connected to CREATED MATCH: " + match.name);
    15.                             trys = 99;
    16.                             yield break;
    17.                         }
    18.                     }
    19.                 }
    20.             }
    21.             manager.matchMaker.CreateMatch(manager.matchName, manager.matchSize, true, "", manager.OnMatchCreate);
    22.             Debugger.Manager.Log("Connected to NEW MATCH: " + name); // this debuggers are a custom ui debug
    23.  
    24.             yield return null;
    25.         }