using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; public class hp : MonoBehaviour { [HideInInspector] public float PlayerHP; [Header("Полоска здоровья")] public Image HPImage; void Start() { PlayerHP = 100; } // Update is called once per frame void Update() { HPImage.fillAmount = PlayerHP/100; if(PlayerHP<=0 && this.gameObject.tag=="Player") { SceneManager.LoadScene(0); } if (PlayerHP <= 0 && this.gameObject.tag == "Enemy") { Destroy(this.gameObject); } } public void SetDamage(float damage) { PlayerHP -= damage; } public void SetHealth(float health) { PlayerHP += health; } }