i have a healthbar using UI Image, then, how to make the healthbar amount decrease when the character get hit by enemy
healthbar script
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class hpBar : MonoBehaviour
{
public Image healthBar;
public void UpdateHealth ()
{
float HP = GetComponent<caroq> ().currentHp ();
healthBar.fillAmount = HP/1;
}
}
and i want to call that function in player script
thank you