JamesMakesGames

EnemyTarget

Feb 24th, 2022
710
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.38 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class EnemyTarget : MonoBehaviour, IDamageable
  4. {
  5.     [SerializeField] private float health;
  6.  
  7.     public void Hit(float damageAmount)
  8.     {
  9.         health -= damageAmount;
  10.  
  11.         if (health <= 0)
  12.         {
  13.             Destroy(gameObject);
  14.         }
  15.     }
  16.  
  17.     public void Damage(float damageAmount)
  18.     {
  19.         Hit(damageAmount);
  20.     }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment