void FixedUpdate() { if (m_controlled) { // always stay on anchor every frame MatchGrabAnchor(); // check if currently exiting if (m_isClimbUpExit) { // wait for end of character animation float fClimbUpExitAnimTime = m_controlled.GetAnim().GetCurrentAnimatorStateInfo(0).normalizedTime; // raise exit power if needed if (m_exitClimbUp.m_maxExitPower > 0f && fClimbUpExitAnimTime >= m_exitClimbUp.m_maxExitPowerAnimTime) { float fClampedInput = GetClampedInput(); m_curExitPower += Time.deltaTime * Time.deltaTime * m_exitClimbUp.m_maxExitPower * fClampedInput; } if (fClimbUpExitAnimTime >= 1f) { // leave control m_isClimbUpExit = false; ReleaseControl(ExitType.ClimbExit); } return; } // do not exit too quickly (wait end of animation in all case) float fAnimTime = m_controlled.GetAnim().GetCurrentAnimatorStateInfo(0).normalizedTime; if ((Time.time - m_grabTime < m_minGrabTime) || fAnimTime < 1f) { return; } // snap to in air handle if grabbing from top and animation is ended (and stop physic animation) /*if (m_bIsGrabbingFromTop && m_controlled.GetAnim().GetCurrentAnimatorStateInfo(0).normalizedTime >= 1f) * { * m_bPhysicAnim = false; * m_bIsGrabbingFromTop = false; * m_curGrabHandle = transform.TransformPoint(m_grabInAir.m_handle); * }*/ // check input for leaving this state is pushed or script is disabled float xValue = m_controlled.m_inputs.m_axisX.GetValue(); float yValue = m_controlled.m_inputs.m_axisY.GetValue(); if (!enabled || (m_controlled.IsFacingRight() && xValue < -m_inputExitBack) || (m_controlled.IsFacingRight() && xValue > m_inputExitFront) || (!m_controlled.IsFacingRight() && xValue > m_inputExitBack) || (!m_controlled.IsFacingRight() && xValue < -m_inputExitFront) || (yValue < -m_inputExitDown)) { ReleaseControl(ExitType.Inputs); } // jump exit else if (m_jumpExit && m_controlled.m_jump.m_button.GetButtonDown()) { ReleaseControl(ExitType.Jump); } else { // handle climb up exit if (m_exitClimbUp.m_enabled && m_exitClimbUp.m_button.IsSpecified() && m_exitClimbUp.m_button.GetButton()) { m_isClimbUpExit = true; // launch player physic exit animation InitPhysAnimation(transform.TransformPoint(m_grabInAir.m_handle)); m_controlled.PlayAnim(m_exitClimbUp.m_anim); } } } }