pgiz3/Assets/Scripts/Target.cs
2026-03-22 03:00:25 +03:00

28 lines
764 B
C#

using UnityEngine;
public class Target : MonoBehaviour
{
public float health = 50f;
public void TakeDamage(float amount)
{
// ДИАГНОСТИКА: Выводим в консоль, сколько урона мы получили
Debug.Log(gameObject.name + " получил " + amount + " урона. Осталось здоровья: " + (health - amount));
health -= amount;
if (health <= 0f)
{
Die();
}
}
void Die()
{
// ДИАГНОСТИКА: Сообщаем, что объект уничтожен
Debug.Log(gameObject.name + " уничтожен!");
// For now, we'll just destroy the target object
Destroy(gameObject);
}
}