Hi my crouch function does not seem to work. When i press the crouch input. Nothing happens. The capsule size does not change. Is my code correct?
Player.h
void ToggleCrouch();
Player.cpp
APlayer::APlayer()
{
PrimaryActorTick.bCanEverTick = true;
GetCharacterMovement()->GetNavAgentPropertiesRef().bCanCrouch = true;
}
void APlayer::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAction("CrouchToggle", IE_Pressed, this, &APlayer::ToggleCrouch);
}
void APlayer::ToggleCrouch()
{
if (GetCharacterMovement()->IsCrouching())
{
UnCrouch();
}
else
{
Crouch();
}
}