Im trying to sync the localScale between all clients however it’s not working for the host, I understand I need to use a Command to update the server, but it doesn’t work…do I have to reference which transform’s localScale is being changed in the Command using a netID or something?
public class Character : NetworkBehaviour {
[SyncVar(hook = "OnScaleChanged")]
public Vector3 playerLocalScale;
public void Left() {
_player.velocity = new Vector2(moveSpeed, _player.velocity.y);
playerLocalScale = new Vector3(-1, 1, 1);
transform.localScale = new Vector3(-1, 1, 1);
CmdOnScaleChanged(playerLocalScale);
}
public void Right() {
_player.velocity = new Vector2(-moveSpeed, _player.velocity.y);
playerLocalScale = new Vector3(1, 1, 1);
transform.localScale = new Vector3(1, 1, 1);
CmdOnScaleChanged(playerLocalScale);
}
public void OnScaleChanged(Vector3 playerLocalScale) {
transform.localScale = playerLocalScale;
Debug.Log(netId + "changed scale");
}
[Command]
public void CmdOnScaleChanged(Vector3 playerLocalScale) {
transform.localScale = playerLocalScale;
}
}
The SyncVar works perfectly and syncs it for clients, however the Command doesn’t work, and thus the host does not see any localScale changes.
SOLVED used Command into RPC