public void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Enemy")) { enemy.GetComponent <NavMeshAgent>().Stop(); } }
private void Search() { if (enemy.navMeshAgent.remainingDistance < 1f) { enemy.navMeshAgent.Stop(); if (enemy.GetComponent <Animator>() != null) { enemy.GetComponent <Animator>().SetFloat("BlendSpeed", -1); } enemy.transform.Rotate(0, enemy.searchingTurnSpeed * Time.deltaTime, 0); searchTimer += Time.deltaTime; if (searchTimer >= enemy.searchingDuration) { enemy.viewCone.setAlarmed(false, 0); ToPatrolState(); } } }
public void ToPatrolState() { enemy.GetComponent <Animator>().SetBool("isMoving", true); enemy.GetComponent <Animator>().SetBool("isRunning", false); enemy.currentState = enemy.patrolState; searchTimer = 0f; }
public void ToChaseState() { enemy.GetComponent <Animator>().SetBool("isMoving", false); enemy.GetComponent <Animator>().SetBool("isRunning", true); enemy.currentState = enemy.chaseState; }