using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class HealthBar : MonoBehaviour {

    Slider slider;

    void Awake() {
        slider = GetComponentInChildren<Slider>();
        slider.value = 1f;
    }

    // Set health to a fraction between 0 and 1
    public void SetHealthFraction(float value) {
        if(value < 0f) {
            slider.value = 0f;
        } else if(value > 1f) {
            slider.value = 1f;
        } else {
            slider.value = value;
        }
    }

}
