/// <summary> /// Checks after secondsToWait if the player is still in line of sight, then switches to shooting/patrol state /// </summary> public IEnumerator CheckIfHeldLineOfSight() { float secondsToWait = 1; float timeWaited = 0; Coroutine ColorCoroutine = colorController.SwitchToHostileColour(); while (timeWaited < secondsToWait) { timeWaited += Time.deltaTime; if (!IsPlayerInView()) { colorController.StopCoroutine(ColorCoroutine); stateHandler.SwitchToLookAroundState(); colorController.SwitchToAwareColour(true); yield break; } yield return(new WaitForFixedUpdate()); } if (stateHandler.IsCurrentState(EnemyStateHandler.States.DetectedPlayer)) { stateHandler.SwitchToShootingState(); } }
public void SwitchToDetectedPlayerState() { colorController.SwitchToAwareColour(); state = States.DetectedPlayer; movement.navAgent.isStopped = true; }