This commit is contained in:
Gerard Gascón 2025-04-24 17:09:22 +02:00
commit 16da8e4dde
333 changed files with 109229 additions and 0 deletions

View file

@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerHealth : MonoBehaviour{
public int maxHp;
[HideInInspector]
public float hp;
public GameObject healthBar;
// Start is called before the first frame update
void Start(){
hp = maxHp;
}
public void TakeDamage(float damage){
hp -= damage;
if (hp > 0 && hp > damage){
healthBar.transform.localScale = new Vector2(hp / maxHp, healthBar.transform.localScale.y);
}else if (hp < damage){
healthBar.transform.localScale = new Vector2(0, healthBar.transform.localScale.y);
}
}
}