So basically… I have a Controller script that is only active on one player at a time, that calls a setter on a “global script” to change a boolean syncvar, and it works fine when the CLIENT player makes the call, but when the HOST makes this same call it’s as though the SyncVar doesn’t ever register that it’s value has been changed and the Debug Log never shows. Could this be a UNET bug or am I missing something?
Something like:
GlobalVars.cs
[SyncVar Onchange=“UpdateClientEngineBool”] public bool EngineOnOff = false;
void UpdateClientEngineBool(bool EngineServerBoolValue)
{
EngineOnOff = EngineServerBoolValue;
}
[Command]
public void CmdSetEngineBoolOnServer(bool EngineBool)
{
EngineOnOff = EngineBool;
Debug.Log(“Setting value”);
}
Then from the script attached to the playerobject:
Controller.cs
private bool EnginePlayerBool = false;
public GameObject GameManager;
if(!isPlayer)
{
if(Input.GetKeyCode(KeyCode.L)
{
EnginePlayerBool = true;
GameManager.GetComponent().CmdSetEngineBoolOnServer(EnginePlayerBool);
}
}