This commit is contained in:
Gerard Gascón 2025-04-24 14:07:24 +02:00
commit a8c6025cd3
158 changed files with 86052 additions and 0 deletions

View file

@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PlayerHealth : MonoBehaviour{
public Image health;
public float hp, maxHp = 12f;
// Start is called before the first frame update
void Start(){
hp = maxHp;
}
// Update is called once per frame
void Update(){
}
public void TakeDamage(float amount){
hp = Mathf.Clamp(hp - amount, 0f, maxHp);
health.transform.localScale = new Vector2(hp / maxHp / 100, 0.00927f);
}
public void AddHealth(float amount){
hp = Mathf.Clamp(hp + amount, 0f, maxHp);
health.transform.localScale = new Vector2(hp / maxHp / 100, 0.00927f);
}
}