Hey! I am having the following problem why trying to make a dodge function. It works, but when I dodge backwards, the player flies a lot further than when he is dodging forwards. Anyone know what the problem is and what I can do about it? Thank you in advance!
InputComponent->BindAction("Forwards", IE_DoubleClick, this, &AFPSCharacter::DodgeFwd);
InputComponent->BindAction("Backwards", IE_DoubleClick, this, &AFPSCharacter::DodgeBwd);
void AFPSCharacter::DodgeFwd()
{
const FVector ForwardDir = FirstPersonCameraComponent->GetForwardVector();
const FVector AddForce = (ForwardDir * plDodgeDist) + FVector(0, 0, 1) * (plDodgeVelocity);
if (CharacterMovement->IsMovingOnGround())
{
LaunchCharacter(AddForce, true, true);
}
if (plMomentum > 0)
{
plMomentum = 0;
}
}
void AFPSCharacter::DodgeBwd()
{
const FVector ForwardDir = FirstPersonCameraComponent->GetForwardVector();
const FVector AddForce = (ForwardDir * (0 - plDodgeDist)) + FVector(0, 0, 1) * (plDodgeVelocity);
if (CharacterMovement->IsMovingOnGround())
{
LaunchCharacter(AddForce, true, true);
}
if (plMomentum > 0)
{
plMomentum = 0;
}
}