void Update() { if (hacked) { if (flag) { Debug.Log("Hack action"); flag = false; switch (motor.GetLastAction()) { case "FrontFlip": motor.StartCoroutine(motor.Spin()); break; case "BackFlip": motor.StartCoroutine(motor.Spin()); break; } } } else { // Enemy logic if (!motor.IsBusy() && body.OnGround() && body.Upright()) { motor.DoNow(motor.Wait(0.5f)); if (dir) { dir = false; //motor.DoAfter(motor.BackFlip()); //motor.StartCoroutine(motor.BackFlip()); } else { dir = true; motor.DoAfter(motor.FrontFlip()); //motor.StartCoroutine(motor.FrontFlip()); } } // Test jumping if (Input.GetKeyDown(KeyCode.F)) { motor.StartCoroutine(motor.FrontFlip()); } } }