Advertisement
FlyingFrog

Untitled

Mar 7th, 2024
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class GWEnemy : MonoBehaviour
  4. {
  5. [SerializeField] private int _maxHealth;
  6.  
  7. private int _currentHealth;
  8.  
  9. private void Start()
  10. {
  11. _currentHealth = _maxHealth;
  12. }
  13.  
  14. public void TakeDamage(int damage)
  15. {
  16. _currentHealth -= damage;
  17. if(_currentHealth <= 0)
  18. {
  19. Destroy(gameObject);
  20. }
  21. }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement