I do not understand why but the player object is null, am I not calling it well?
public class HealthBar : MonoBehaviour {
Vector3 localScale;
public Transform HealthTransform;
public Player PlayerObj;
void Start () {
localScale = HealthTransform.localScale;
PlayerObj = new Player();
}
void Update () {
if(PlayerObj.GetPlayerAxis().Equals("P1Horizontal"))
{
localScale.x = Player.HealthAmountP1;
if (gameObject.name.Equals("P1Health"))
{
HealthTransform.localScale = localScale;
}
}
if (PlayerObj.GetPlayerAxis().Equals("P2Horizontal"))
{
localScale.x = Player.HealthAmountP2;
if(gameObject.name.Equals("P2Health"))
{
HealthTransform.localScale = localScale;
}
}
}
}