private IEnumerator StartAttack() { hasAction = true; navAgent.isStopped = true; anim.SetBool("Walking", false); anim.SetTrigger("Attack"); yield return(new WaitForSeconds(2)); if (disabledMovement) { yield break; } if (CharUtil.IsTargetWithinRange(transform, playerTransform.position, attackRange)) { playerTransform.GetComponent <HealthManager>().TakeDamage(10f); } yield return(new WaitForSeconds(2)); if (disabledMovement) { yield break; } anim.SetBool("Walking", true); navAgent.isStopped = false; hasAction = false; yield break; }
private void Patrol() { if (CharUtil.IsTargetWithinRange(transform, playerTransform.position, visibleRange)) { StartChasing(); } else if (CharUtil.IsTargetWithinRange(transform, playerTransform.position, 1f)) { StartIdling(); } }
private void Idle() { if (CharUtil.IsTargetWithinRange(transform, playerTransform.position, visibleRange)) { StartChasing(); } else if (outIdleDuration <= 0f) { StartPatrol(); } else { outIdleDuration -= Time.deltaTime; } }
private void Chase() { if (CharUtil.IsTargetWithinRange(transform, playerTransform.position, visibleRange)) { if (CharUtil.IsTargetWithinRange(transform, playerTransform.position, attackRange)) { StartCoroutine(StartAttack()); } else { navAgent.SetDestination(playerTransform.position); } } else { StartIdling(); } }