1
Fork 0
slime-blood-and-pain/Assets/Scripts/FillAmountFromPlayerHP.cs

26 lines
616 B
C#
Raw Permalink Normal View History

2019-04-28 12:41:28 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FillAmountFromPlayerHP : MonoBehaviour
{
2019-04-28 14:34:50 +00:00
private EntityPlayer player;
2019-04-28 12:41:28 +00:00
private Image image;
2019-04-29 12:39:10 +00:00
public bool max;
2019-04-28 12:41:28 +00:00
private void Start() {
2019-04-28 14:34:50 +00:00
player = GameObject.FindGameObjectWithTag("Player").GetComponent<EntityPlayer>();
2019-04-28 12:41:28 +00:00
image = GetComponent<Image>();
}
private void Update() {
2019-04-29 12:39:10 +00:00
if(max) {
image.fillAmount = player.hpMax / player.hpTrueMax;
}
else {
image.fillAmount = player.hp / player.hpTrueMax;
}
2019-04-28 12:41:28 +00:00
}
}