//timer for 10 seconds public IEnumerator KeepStillTime() { //guard boolean to make sure the movementCheck is only relevant for these 10 seconds keepStillTriggered = true; initialDeviceRotation = DeviceRotation.GetRotation().eulerAngles; // Notify the AI that they need to run away and whatnot if (witchArriveEvent != null) { witchArriveEvent(); } for (int i = (int)keepStillDuration; i >= 1; i--) { //if we moved, stop the timer if (!isStill) { yield return(new WaitForSecondsRealtime(2.5f)); loadLevelScript.LoadSavedLevel(true); break; } yield return(new WaitForSecondsRealtime(1)); } keepStillTriggered = false; //if we stayed still for the full time, prompt user and then clear text if (isStill) { witchPromptText.text = "WELL DONE!"; yield return(new WaitForSecondsRealtime(1)); } witchPromptText.text = " "; if (witchLeaveEvent != null) { witchLeaveEvent(); } reset(); }