I got the following Code to enable locally a gameobject (canvasUI) on a client once some client interacts with an item:
[SerializeField]
private GameObject _questPanel;
[SyncVar(hook = "LobbyStart")]
private bool _activateSideQuestPanel;
public void GameLobbyStart()
{
if (isServer)
{
_activateSideQuestPanel = !_activateSideQuestPanel;
}
else
{
CmdLobbyStart();
}
}
[Command]
private void CmdLobbyStart()
{
_activateSideQuestPanel = !_activateSideQuestPanel;
}
private void LobbyStart(bool oldValue, bool newValue)
{
_questPanel.SetActive(newValue);
Debug.Log("Activate???");
}
The methods are called correctly and I can see in the logs "Activate???" on Client2 when Client1 interacts, meaning that LobbyStart() does run. But only the local client that executed the method GameLobbyStart() sees the object as active. Any idea why? I understand due to authority a player can't interact with another player's game objects but since we are telling the players to locally run a method, I would expect it to work?