using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class HydrationBar : MonoBehaviour { private Slider slider; public Text hydrationCounter; public GameObject playerState; private float currentHydration, maxHydration; // Start is called before the first frame update void Awake() { slider = GetComponent(); } // Update is called once per frame void Update() { currentHydration = playerState.GetComponent().currentHydration; maxHydration = playerState.GetComponent().maxHydration; float fillValue = currentHydration/maxHydration; slider.value = fillValue; hydrationCounter.text = currentHydration+"%"; } }