Okay! so I’m fairly new to unity networking and the unity community so I apologize in advance. Currently, I’m trying to sync the variable “Hp” across the network with this code;
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class HealthSync : NetworkBehaviour {
[SyncVar] public int Hp=100;
[Command]
public void CmdDamage(int dmg){
Hp -= dmg;
}
}
and this code to change ‘Hp’
hit.collider.gameObject.GetComponent ().CmdDamage(LaserDamage);
currently when player 1 shoots player 2, player 2’s health changes on player 1’s screen but not on player 2’s screen!
Any thoughts on what the problem is and how to fix it? Thanks!