There seems to be inconsistent behaviour in the following couple methods.
When the following code is binded and called successfully, the crouching is actually smooth.
void APlayerFPSCharacter::StartCrouching()
{
if (!bIsCrouching)
{
UE_LOG(LogTemp, Warning, TEXT("Crouch"));
bIsCrouching = true;
GetCharacterMovement()->MaxWalkSpeed = CrouchingSpeed;
GetCapsuleComponent()->SetCapsuleHalfHeight(ColliderHalfHeight);
}
But when the following gets called:
void APlayerFPSCharacter::EndCrounching()
{
float CapsulleFullHeight = 96.f;
if (bIsCrouching)
{
bIsCrouching = false;
UE_LOG(LogTemp, Warning, TEXT("Stand UP"));
GetCharacterMovement()->MaxWalkSpeed = DefaultWalkSpeed;
GetCapsuleComponent()->SetCapsuleHalfHeight(CapsulleFullHeight);
}
}
It’s no longer Smooth. Neither fucntion is an override, and both are binded like this:
EnhancedInputComponent->BindAction(
StartCrouchAction, ETriggerEvent::Started, this,
&APlayerFPSCharacter::StartCrouching);
EnhancedInputComponent->BindAction(
StartCrouchAction, ETriggerEvent::Completed, this,
&APlayerFPSCharacter::EndCrounching);
So i’m left wondering, why does the first time it’s called, it automatically applies some form of Lerp, or Timeline to smooth the reduction of the capsule, but it is inmediate when it’s set to 96?
Thanks!