private IEnumerator Look(float rotationAmount) { //looks to the right Quaternion finalRotation = Quaternion.Euler(0, rotationAmount, 0) * this.transform.rotation; while (transform.rotation != finalRotation) { playerFound = coneVision.Look(); this.transform.rotation = Rotate(finalRotation, rotationSpeed); yield return(0); } //back looking forward finalRotation = Quaternion.Euler(0, -rotationAmount, 0) * this.transform.rotation; while (transform.rotation != finalRotation) { playerFound = coneVision.Look(); this.transform.rotation = Rotate(finalRotation, rotationSpeed); yield return(0); } //look to the left finalRotation = Quaternion.Euler(0, -rotationAmount, 0) * this.transform.rotation; while (transform.rotation != finalRotation) { playerFound = coneVision.Look(); this.transform.rotation = Rotate(finalRotation, rotationSpeed); yield return(0); } looking = false; }
//if the player is detected: // - because he is seen // - because he is in the listening range // - because the agent is hit public bool PlayerDetected() { return(coneVision.Listen(listeningRange) || coneVision.Look() || health.CheckDamage()); }