I was trying to make a health bar for my character and I have a model that scales on the x axis whenever the player takes damage but, it doesn't scale evenly. How could i fix this? Is it easier to just use a GUI texture?
public override void TakeDamage (float dmg)
{
gui.PlayerHealth(dmg/Health);
base.TakeDamage (dmg);
}
using UnityEngine;
using System.Collections;
public class GameGUI : MonoBehaviour
{
public Transform HealthBar;
public void Start()
{
HealthBar.localScale = Vector3.zero;
}
public void PlayerHealth(float dmg)
{
HealthBar.localScale = new Vector3(dmg,1,1);
}
}
↧