Files
Crash-Course/Assets/Scripts/HealthBar.cs

25 lines
424 B
C#
Raw Normal View History

2025-02-26 20:17:19 -05:00
using UnityEngine;
using UnityEngine.UI;
public class HealthBar : MonoBehaviour
{
public Slider slider;
public void SetMaxHealth(float health)
{
2025-02-26 23:09:27 -05:00
if (slider != null)
{
slider.maxValue = health;
slider.value = health;
}
2025-02-26 20:17:19 -05:00
}
public void SetHealth(float health)
{
2025-02-26 23:09:27 -05:00
if (slider != null)
{
slider.value = health;
}
2025-02-26 20:17:19 -05:00
}
}