- Home /
Question by
Roiw · Feb 04, 2016 at 03:33 PM ·
networkingnetworksynchronizationsync
SyncVar works with disabled components?
Hello everybody,
I have a command that changes a bool on my server. On the server side I can see that the bool has changed to the value that I want but the changes never made it to the clients. I wonder if its because on the server the script is disabled ( It's my character script that's why its disabled.').
This is my command.
[Command]
public void CmdGetMissile(GameObject missileToGet)
{
Debug.Log ("Player Collecting Missile!");
// Displays the missile on the player
MissileBack.SetActive(true);
// Delete old missile.
NetworkServer.Destroy(missileToGet);
// Hook the missile to the player
this.hasMissile = true;
// Update the PickupManager on the server
GameObject.Find ("PickupManager").GetComponent<PickupManager>().missileList[missileToGet.GetComponent<Missile>().posIndex] = false;
}
This is my SyncVar
[SyncVar(hook="OnChangeHasMissile")]
public bool hasMissile = false;
// This runs on clients
public void OnChangeHasMissile( bool newValue)
{
Debug.Log("OnChangeHasMissile hook has been achieved");
hasMissile = newValue;
MissileBack.SetActive (true);
}
What do you guys think? Is it because the component is not enabled on the server? Did I miss something?
Comment
Your answer
Follow this Question
Related Questions
[SyncVar] protect Cheat Engine 0 Answers
Networking Sync SetActive Not Working 0 Answers
How fast do Syncvars synchronize? 1 Answer