I'm making an online multiplayer game with Unity and MLAPI. I wrote the script below and placed it in my scene, meaning each client and server should run it when a scene loads. The server is supposed to set the variable to 1
, but it's not changing on the clients!
using UnityEngine;
using MLAPI;
using MLAPI.Messaging;
using MLAPI.NetworkVariable;
public class TestNetwork : NetworkBehaviour
{
public NetworkVariableInt Test = new NetworkVariableInt(-1);
void Start() {
if (!NetworkManager.Singleton.IsServer) return;
Test.Value = 1;
}
void Update() {
Debug.Log($"{Test.Value}");
}
}