Double Jump Problem

Hello guys.

I have a problem with my double jump code. Whenever I press the jump key the character keeps jumping in the air.

I changed JumpMaxCount to 2 but nothings changed.

bFirstJump=true; by default and rest of the code

Screenshot_1


Thanks in advance.

Edit: If I delete these codes and change JumpMaxCount to 2 in BP the character jumps twice but I don’t know if I could change the values of second jump.

MaxJumpCount is tied to the normal character Jump, however what’s happening is you’re doing a Jump on the first DoubleJump press, and then every subsequent DoubleJump is doing a LaunchCharacter which is unconcerned by the number of “jumps” you’ve performed (it only has to not be the bFirstJump and thus can happen with every DoubleJump press).

I haven’t modified the normal character Jump mechanics myself yet, but if it helps, some thoughts I have are adjusting what you’re currently doing:

  • Track your own integer of the number of jumps instead of just bFirstJump
  • Increment it every DoubleJump press
  • Reset it on Landed like you are doing for bFirstJump
  • Make sure your LaunchCharacter only happens if the number of jumps is less than 2 to ensure it only goes off on the second press

Or, alternatively, you could…

  • Make use of the existing JumpMaxCount and JumpCurrentCount character variables
  • Maybe give a little LaunchCharacter boost onJumped if the JumpCurrentCount is > 1, if that’s what you’re wanting to happen in addition to the regular second jump.

@Bill Thanks for the reply.

I think I solve the problem with my code. If anyone has the same issue I changed the code to this →

void APlayableChar::DoubleJump()
{
if(JumpingCount<=1)
{
ACharacter::LaunchCharacter(FVector(0.0f, 0.0f, 500.f), false, true);
JumpingCount++;
}
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.