Skip to content
Snippets Groups Projects
EnergyBarController.cs 439 B
Newer Older
using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class EnergyBarController : MonoBehaviour
{
    private Image bar;

    private void Start()
    {
        bar = GetComponent<Image>();
        PlayerController.staminaUse += updateState;
    }

    private void updateState(float stamina)
    {
        bar.fillAmount = stamina / 10;
        bar.color = Color.Lerp(Color.red, Color.green, bar.fillAmount);
    }
}