Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Enemy : MonoBehaviour
- {
- protected int damage;
- protected int health;
- protected GameObject player;
- void Start()
- {
- player = GameObject.FindObjectOfType<PlayerMove>().gameObject;
- }
- void Update()
- {
- if(player==null)
- return;
- Move();
- Attack();
- }
- public void ChangeHealth(int hp)
- {
- health += hp;
- if(health<=0)
- Dead();
- }
- public void Dead()
- {
- GetComponent<Animator>().SetBool("dead", true);
- GetComponent<CharacterController>().enabled = false;
- GetComponent<Enemy>().enabled = false;
- }
- protected virtual void Attack()
- {
- }
- protected virtual void Move()
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement