22 lines
521 B
C#
22 lines
521 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class SpriteHealthBar : MonoBehaviour
|
|
{
|
|
private Vector3 startScale;
|
|
|
|
public Transform healthBarFill;
|
|
|
|
public float health;
|
|
void Awake()
|
|
{
|
|
startScale = healthBarFill.localScale;
|
|
}
|
|
|
|
public void SetHealth(float amount){
|
|
health = amount;
|
|
float amountMult = amount / 100f;
|
|
healthBarFill.localScale = new Vector3(startScale.x * amountMult, startScale.y,startScale.z );
|
|
}
|
|
} |