Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- void Awake()
- {
- slider = GetComponent<Slider>();
- }
- void Update()
- {
- currentHydration = playerState.GetComponent<PlayerState>().currentHydrationPercent;
- maxHydration = playerState.GetComponent<PlayerState>().maxHydrationPercent;
- float fillValue = currentHydration / maxHydration;
- slider.value = fillValue;
- hydrationCounter.text = currentHydration + "%";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement