I am working on a multiplayer prototype and am trying to get health bars working. It's working on server side and health is working and subtracting from client side with a network variable, however I cannot get the slider to update properly.
private void OnTriggerEnter(Collider other)
{
if (IsServer)
{
if (other.GetComponent<PlayerNetworkHealth>() != null)
other.GetComponent<PlayerNetworkHealth>().DepleteHealthClientRpc(damage);
}
}
[ClientRpc]
public void DepleteHealthClientRpc(int value)
{
if (!IsServer) return;
health.Value -= value;
healthBar.value = health.Value;
if (health.Value <= 0)
Debug.Log("Dead");
}
Any info would be appreciated. Im at a loss.