using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI; // HERE
public class PlayerHealth : MonoBehaviour
{
[SerializeField] float hitPoints = 100f;
[SerializeField] Image healthBar = null; // HERE
public void TakeDamage(float damage)
{
hitPoints -= damage;
// HERE
if (healthBar != null)
{
healthBar.fillAmount = hitPoints / 100f;
}
if (hitPoints <= 0)
{
GetComponent<DeathHandler>().HandleDeath();
}
}
}
This is my player health script, which involves my health bar. This decreases as player health decreases. However, over time I want my player to regain health. How would I do this? I assume I use time.deltaTime