how to make your health bar go down when a bullet hits your player unity code example
Example: how to make your health bar go down when a bullet hits your player unity
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
TakeDamage(20);
}
}
void TakeDamage(int damage)
{
currentHealth -= damage;
healthbar.SetHealth(currentHealth);
}