Advertisement
kadyr

Untitled

Oct 13th, 2021
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Enemy : MonoBehaviour
  6. {
  7. protected int damage;
  8. protected int health;
  9. protected GameObject player;
  10.  
  11. void Start()
  12. {
  13. player = GameObject.FindObjectOfType<PlayerMove>().gameObject;
  14. }
  15. void Update()
  16. {
  17. if(player==null)
  18. return;
  19. Move();
  20. Attack();
  21. }
  22.  
  23.  
  24. public void ChangeHealth(int hp)
  25. {
  26. health += hp;
  27. if(health<=0)
  28. Dead();
  29. }
  30.  
  31.  
  32. public void Dead()
  33. {
  34. GetComponent<Animator>().SetBool("dead", true);
  35. GetComponent<CharacterController>().enabled = false;
  36. GetComponent<Enemy>().enabled = false;
  37. }
  38.  
  39. protected virtual void Attack()
  40. {
  41.  
  42. }
  43. protected virtual void Move()
  44. {
  45.  
  46. }
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement