/// <summary> /// Called to do a climb jump /// </summary> private void PerformClimbJump(Vector3 targetDirection, ClimbJumpType targetClimbJump) { m_FinishOnAnimationEnd = true; m_HasJumpFromLedge = true; m_JumpDirection = targetDirection; m_ClimbJumpType = targetClimbJump; }
public override void OnExitAbility() { if (m_ClimbIK != null) { m_ClimbIK.OnHang = false; } if (m_HasJumpFromLedge && m_ClimbJumpType != ClimbJumpType.Drop) { if (m_ClimbJumpType == ClimbJumpType.Up) { m_ClimbJump.StartHopUp(GrabPosition, transform.position + transform.forward * characterOffset.z + Vector3.up * m_VerticalLinecastStartPoint, UseLaunchMath); } else { m_ClimbJump.StartClimbJump(m_ClimbJumpType, m_JumpDirection, GrabPosition, m_VerticalLinecastStartPoint, UseLaunchMath, CurrentLedgeTransform.GetComponent <Collider>()); } } m_FinishOnAnimationEnd = false; m_SideAdjustment = false; m_JumpDirection = Vector3.zero; m_ClimbJumpType = ClimbJumpType.Back; m_System.UpdatePositionOnMovableObject(null); base.OnExitAbility(); }
public override void UpdateAbility() { base.UpdateAbility(); float forwardValue = m_InputManager.Move.y; switch (CurrentCastResult) { case LadderCastResult.Bottom: if (FreeAbove()) { SetState(m_ClimbUp); m_System.m_Capsule.enabled = false; } else { if (m_InputManager.jumpButton.WasPressed && forwardValue > 0.5f) { SetState(m_HopUpStart); m_JumpDirection = ClimbJumpType.Up; } } forwardValue = Mathf.Clamp(forwardValue, -1f, 0); break; case LadderCastResult.Top: forwardValue = Mathf.Clamp(forwardValue, 0, 1f); break; } if (m_JumpDirection == ClimbJumpType.Noone) { if (m_InputManager.jumpButton.WasPressed) { if (m_InputManager.Move.x > 0.5f) { SetState(m_HopRightStart); m_JumpDirection = ClimbJumpType.Right; return; } if (m_InputManager.Move.x < -0.5f) { SetState(m_HopLeftStart); m_JumpDirection = ClimbJumpType.Left; return; } } if (m_InputManager.dropButton.WasPressed) { m_JumpDirection = ClimbJumpType.Drop; } } m_AnimatorManager.SetForwardParameter(forwardValue, 0.05f); }
/// <summary> /// Set parameters to jump /// </summary> /// <param name="data">launch data</param> /// <param name="targetJumpType">Jump Type that character will jump</param> private void SetLaunchParameters(LaunchData data, ClimbJumpType targetJumpType) { m_CharacterDesiredVelocity = data.initialVelocity; // Use data velocity m_CharacterDesiredRotation = (targetJumpType == ClimbJumpType.Up) ? transform.rotation : GetRotationFromDirection(m_CharacterDesiredVelocity.normalized); // Get rotation to face to point m_JumpTimeToTarget = data.timeToTarget; // Get total time to reach the target m_JumpType = targetJumpType; // Set desired jump direction }
public override void OnEnterAbility() { base.OnEnterAbility(); m_System.m_Rigidbody.useGravity = false; m_System.m_Rigidbody.velocity = Vector3.zero; updatingPosition = true; EnterTargetPosition = TargetPosition; if (EnterTargetPosition.y < m_CurrentLadderCollider.bounds.min.y) { EnterTargetPosition.y = m_CurrentLadderCollider.bounds.min.y; } EnterTargetRotation = GetRotationFromDirection(m_CurrentLadderCollider.transform.forward); deltaPos = Vector3.Distance(EnterTargetPosition, transform.position) / transitionTimeToPosition; time = 0; m_JumpDirection = ClimbJumpType.Noone; CurrentCastResult = LadderCastResult.Both; }
/// <summary> /// Star a climb jump /// </summary> /// <param name="jumpType">Desired jump type</param> /// <param name="directionVector">Direction to jump</param> /// <param name="GrabPosition">Grab position on character</param> /// <param name="LinecastStartHeight">Point that starts cast</param> /// <returns>Time to reach the target point</returns> public float StartClimbJump(ClimbJumpType jumpType, Vector3 directionVector, Vector3 GrabPosition, float LinecastStartHeight, bool abilityUseMath, Collider ignoreCollider = null) { m_JumpType = jumpType; if (m_UseLaunchMath && abilityUseMath) { LaunchCharacter(directionVector, GrabPosition, LinecastStartHeight, ignoreCollider); } else { JumpParameters parameter = new JumpParameters(); // Choose jump parameters based on Jump Type switch (m_JumpType) { case ClimbJumpType.Right: parameter = HopRightParameters; break; case ClimbJumpType.Left: parameter = HopLeftParameters; break; case ClimbJumpType.Back: parameter = JumpBackParameters; break; } SetLaunchParameters(GetLaunchFromParameters(parameter, directionVector), m_JumpType); if (m_JumpType != ClimbJumpType.Back) { m_CharacterDesiredRotation = transform.rotation; } } m_ForceEnterAbility = true; m_DotResult = Quaternion.Dot(transform.rotation, m_CharacterDesiredRotation); return(m_JumpTimeToTarget); }
public override void UpdateAbility() { base.UpdateAbility(); // Forward value to be used in the animator controller float forwardValue = m_InputManager.Move.y; // Constantly check ladder switch (CurrentCastResult) { case LadderCastResult.Bottom: // Climb Up if (FreeAbove()) { SetState(m_ClimbUp); m_System.m_Capsule.enabled = false; } else // Check to Hop Up { if (m_InputManager.jumpButton.WasPressed && forwardValue > 0.5f) { SetState(m_HopUpStart); m_JumpDirection = ClimbJumpType.Up; } } // Stop Moving Up forwardValue = Mathf.Clamp(forwardValue, -1f, 0); break; case LadderCastResult.Top: //Stop climbing down forwardValue = Mathf.Clamp(forwardValue, 0, 1f); break; } if (m_JumpDirection == ClimbJumpType.Noone) { if (m_InputManager.jumpButton.WasPressed) { // Side Jumps if (m_InputManager.Move.x > 0.5f) { SetState(m_HopRightStart); m_JumpDirection = ClimbJumpType.Right; return; } if (m_InputManager.Move.x < -0.5f) { SetState(m_HopLeftStart); m_JumpDirection = ClimbJumpType.Left; return; } } if (m_InputManager.dropButton.WasPressed) { m_JumpDirection = ClimbJumpType.Drop; } } m_AnimatorManager.SetForwardParameter(forwardValue, 0.05f); }