// Update is called once per frame void Update() { RotateToDestination(m_direction.getDirection(), m_turningSpeed); m_moveForward.Update(); // detect player end movement. if (m_endMotionDetector != null && m_endMotionDetector.IsMotionEnded(m_rigidbody.transform.position, m_rigidbody.transform.rotation)) { // the variable is not null once the player started moving and once the movement ended the variable must // be set to null again m_endMotionDetector = null; m_progressbarCloned = Instantiate(m_progressbar, new Vector3(Screen.width / 2, Screen.height / 4, 0), Quaternion.identity); } }