Advertisement
kadyr

Untitled

Sep 25th, 2021
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 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<PlayerController>().gameObject;
  14. }
  15. void Update()
  16. {
  17. Move();
  18. Attack();
  19. }
  20.  
  21.  
  22. public void ChangeHealth(int hp)
  23. {
  24. health += hp;
  25. if(health<=0)
  26. Dead();
  27. }
  28.  
  29.  
  30. public void Dead()
  31. {
  32. GetComponent<Animator>().SetBool("dead", true);
  33. GetComponent<CharacterController>().enabled = false;
  34. GetComponent<Enemy>().enabled = false;
  35. }
  36.  
  37. protected virtual void Attack()
  38. {
  39.  
  40. }
  41. protected virtual void Move()
  42. {
  43.  
  44. }
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement