public void OnHit(HitInfo info) { if (killable.GetHealth() <= 1) { Destroy(this.GetComponent <EnemyChaseController>()); Destroy(head); EnemyFleeController newController = this.gameObject.AddComponent <EnemyFleeController>(); newController.direction = info.direction; } }
// Start is called before the first frame update void Start() { currentState = BasicRangeState.Idle; player = GameObject.FindGameObjectWithTag("Player"); playerGridPosition = player.GetComponent<GridPosition>(); playerHealth = player.GetComponent<PlayerHealth>(); gridPosition = GetComponent<GridPosition>(); aStar = GetComponent<AIPath>(); attackCooldownCounter = 0; attackTimeCounter = 0; canAttack = false; fleeController = GetComponent<EnemyFleeController>(); animator = GetComponentInChildren<Animator>(); monsterHealth = GetComponent<MonsterHealth>(); stateCounter = 0; }