IEnumerator StateSwitch(StateMachine stateMachine) { for (;;) { string currentState = stateMachine.getCurrentState().ToString(); // <<-----------------------------------------------------------------------------** // Enter "Aiming" state on right click press // Else: Exit "Aiming" and Enter "DefaultPlayer" // Bool Controls if Camera Lerps Positions between states // **---------------------------------------------** if (Input.GetMouseButton(1) == true) { //Debug.Log("StateMachine: Right Mouse Pressed"); if (currentState != "Aiming") { // TODO: camController.SetCamTarget(Ref_CamAiming.transform.position); if (LerpCamera) { camController.SetTargetCameraPos(camAimingDist, aimingOffset); } else { camController.SetPos(camAimingDist, aimingOffset); } stateMachine.ChangeState(new Aiming(this, animator)); animator.SetBool("isAiming", true); } } if (Input.GetMouseButton(1) == false) { if (currentState != "DefaultPlayer") { // TODO: camController.SetCamTarget(Ref_CamDefault.transform.position); if (LerpCamera) { camController.SetTargetCameraPos(defCamDist, defOffset); } else { camController.SetPos(defCamDist, defOffset); } stateMachine.ChangeState(new DefaultPlayer(this, animator)); animator.SetBool("isAiming", false); //Debug.Log("StateMachine: Right Mouse NOT Pressed"); } } // **----------------------------------------------------------------------------->> yield return(new WaitForSeconds(.1f)); } }