You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RatAttack2D/Assets/Scripts/HpBar.cs

23 lines
520 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HpBar : MonoBehaviour
{
public Health HP;
private Slider Fill;
private float m;
private void Start()
{
Fill = transform.Find("Slider").GetComponent<Slider>();
Fill.maxValue = HP.MaxHP;
Fill.value = HP.Hp;
}
private void FixedUpdate()
{
Fill.maxValue = HP.MaxHP;
Fill.value = Mathf.SmoothDamp(Fill.value, HP.Hp, ref m, 0.1f);
}
}