Hey! I have been having some difficulty on getting a good crouch going for my game. I am using this code at the moment, which works pretty well:
void AFPSCharacter::StartCrouch()
{
if (CharacterMovement->IsMovingOnGround())
{
isCrouched = true;
CharacterMovement->bWantsToCrouch = true;
}
}
void AFPSCharacter::EndCrouch()
{
if (CharacterMovement->IsMovingOnGround())
{
isCrouched = false;
CharacterMovement->bWantsToCrouch = false;
}
}
The problem is that the player crouches immediatly, without any type of crouching motion or delay, so it looks very unnatural. This on the other hand, works perfectly…
void AInstinctCharacter::StartCrouch()
{
if (CharacterMovement->IsMovingOnGround())
{
Crouch();
}
}
void AInstinctCharacter::EndCrouch()
{
if (CharacterMovement->IsMovingOnGround())
{
UnCrouch(true);
}
}
…but “EndCrouch()” does not work for whatever reason. Anyone know why? Thank you in advance! I implemented it as follows:
InputComponent->BindAction("Crouch", IE_Pressed, this, &AFPSCharacter::StartCrouch);
InputComponent->BindAction("Crouch", IE_Released, this, &AFPSCharacter::EndCrouch);