The repeated jump does not work when the character does not jump from grounded state.
Expected behaviour: Character runs off a cliff -> is in mid air -> user presses the jump button -> Character uses the repeated jump
Current behaviour: repeated jump will not be used, unless the Charater jumps off the cliff
Fix at line 150 in Jump.cs, right below the "else" from the
insert:
full CanStartAbility() method below:
Expected behaviour: Character runs off a cliff -> is in mid air -> user presses the jump button -> Character uses the repeated jump
Current behaviour: repeated jump will not be used, unless the Charater jumps off the cliff
Fix at line 150 in Jump.cs, right below the "else" from the
if (m_CharacterLocomotion.Grounded) { }else{ }
,insert:
C#:
// allow repeated jump even if the character did run off a ledge and did not jump
// in the first place
if (m_RepeatedJumpCount < m_MaxRepeatedJumpCount)
{
m_JumpApplied = true;
return true;
}
full CanStartAbility() method below:
C#:
public override bool CanStartAbility()
{
// An attribute may prevent the ability from starting.
if (!base.CanStartAbility()) {
return false;
}
if (m_MinCeilingJumpHeight != -1) {
// Ensure the space above is clear to get off of the ground.
if (m_CharacterLocomotion.SingleCast(m_CharacterLocomotion.Up * (m_MinCeilingJumpHeight + m_CharacterLocomotion.SkinWidth + m_CharacterLocomotion.ColliderSpacing),
Vector3.zero, m_CharacterLayerManager.SolidObjectLayers, ref m_RaycastResult)) {
return false;
}
}
if (m_CharacterLocomotion.Grounded) {
// The character can't jump if they aren't on the ground nor if they recently landed.
if (m_LandTime + m_RecurrenceDelay > Time.time) {
return false;
}
// The character can't jump if the slope is too steep.
var slope = Vector3.Angle(m_CharacterLocomotion.Up, m_CharacterLocomotion.GroundRaycastHit.normal);
if (slope > m_CharacterLocomotion.SlopeLimit) {
return false;
}
} else {
// allow repeated jump even if the character did run off a ledge and did not jump
// in the first place
if (m_RepeatedJumpCount < m_MaxRepeatedJumpCount)
{
m_JumpApplied = true;
return true;
}
// Allow the ability to start if the character is in the air before the grounded grace period. This allows the character to run off a ledge but still
// be able to jump. The character may also be able to do a repeated jump even if the character isn't grounded.
if ((!m_JumpApplied && m_InAirTime + m_GroundedGracePeriod <= Time.time) ||
(m_RepeatedJumpCount != -1 && m_RepeatedJumpCount > m_MaxRepeatedJumpCount) ||
(m_JumpTime != -1 && m_JumpTime + m_RecurrenceDelay > Time.time)) {
return false;
}
}