This commit is contained in:
김도환
2026-05-10 02:13:54 +09:00
parent e8ce7eb653
commit ee05d6eda9
23 changed files with 549 additions and 148 deletions

View File

@@ -0,0 +1,31 @@
using System;
using UnityEngine;
namespace Unicorn
{
public class HpBar : MonoBehaviour
{
private LivingEntity _parent;
public GameObject fill;
private void Start()
{
if (!transform.parent.TryGetComponent(out _parent))
{
gameObject.SetActive(false);
return;
}
UpdateHealth();
}
public void UpdateHealth()
{
var scale = Math.Max(_parent.health, 0f) / _parent.maxHealth;
fill.transform.localScale = new Vector3(scale, 1, 1);
fill.transform.localPosition = new Vector3((scale-1) / 2, 0, 0);
//1 -> 0
//0 -> -0.5
}
}
}