How to sync variables.

public static int lvl = 0;
bool isLocked = false;
int temp = 0;
// Use this for initialization
void OnEnable () {
if (!isLocked)
{
temp = Random.Range(0, 10);
UnityEngine.Debug.Log(isLocked);
GetComponent().RPC("UpdateVariables", PhotonTargets.All);
}
}
[PunRPC]
void UpdateVariables()
{
lvl = temp;
isLocked = true;
}
// Update is called once per frame
void Update () {
UnityEngine.Debug.Log(isLocked);
}

Comments