using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class HealthBar : MonoBehaviour { private Slider slider; public GameObject player; private void Start() { slider = GetComponent(); slider.maxValue = player.GetComponent().health; } private void Update() { if(player != null) { slider.value = player.GetComponent().health; } } }