/
RealMotya
/
Platformer
Обзор
Документация
Войти
/
RealMotya
/
Platformer
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Assets/_Scripts/Character.cs
44 строки
707 B
VR4\IT-Cube28
Fear: добавил босса
29 янв 2026, 10:37
29 янв 2026, 10:37
ebc6168
Код
Авторство
О чём код?
using UnityEngine; public abstract class Character : MonoBehaviour { [SerializeField] protected int _startHealth; protected int _health; protected bool _isImmortal = false; public void Start() { _health = _startHealth; } public virtual void GetDamage(int damage) { if (_isImmortal == true) { return; } _health -= damage; Debug.Log(_health); _isImmortal = true; Invoke("CancelImmortal", 1f); if (_health <= 0) { Death(); } } public abstract void Death(); private void CancelImmortal() { _isImmortal = false; } }