I’ve spent the last day working on getting a double jump to work and replicate across the network and it’s working pretty well so far. The only problem I’m having now is that I can’t make the double jump change the character’s horizontal velocity. I’d like the character to move in the direction that the controls are held when the second jump is triggered. The problem right now seems to be that the air control value is stopping me from changing Velocity. This is my code so far:
bool UShooterCharacterMovement::DoJump(bool bReplayingMoves)
{
if (Cast<AShooterCharacter>(GetCharacterOwner())->GetJumpCount() > 1)
{
if (!bConstrainToPlane || FMath::Abs(PlaneConstraintNormal.Z) != 1.f)
{
Velocity.Z = JumpZVelocity*DoubleJumpHeightMultiplier;
//Calculate current speed
FVector horizontalMovement = Velocity;
horizontalMovement.Z = 0.0f;
float speed = horizontalMovement.Size();
//Change direction of velocity in mid-jump
horizontalMovement = GetPendingInputVector();
horizontalMovement *= speed;
Velocity.X = horizontalMovement.X;
Velocity.Y = horizontalMovement.Y;
SetMovementMode(MOVE_Falling);
return true;
}
}
return Super::DoJump(bReplayingMoves);
}
Does this look like the AirControl value is stopping me from moving? Or is there another physics value I’d need to change in order to move in the direction I want?