ProjetAMJV_CR/Assets/Scripts/UnitScripts/Bars/HealthBars.cs

23 lines
590 B
C#

using UnityEngine;
using UnityEngine.UI;
public class HealthBar : MonoBehaviour
{
[SerializeField] private HealthHandler healthHandler;
[SerializeField] private Slider healthSlider;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
healthSlider.maxValue = healthHandler.MaxHealth;
}
void Update()
{
healthSlider.value = healthHandler.CurrentHealth;
}
// Update is called once per frame
void LateUpdate()
{
transform.LookAt(Camera.main.transform);
}
}