Could I get some help with crouching using C++?

I’m having issues getting my fps character to crouch in the c++ code. Some of my code is below.

.h

UFUNCTION()
		void CrouchStart();

.cpp

void AFPSCharacter::CrouchStart()
{
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, TEXT("Crouch Started "));
	

	

    if (CharacterMovement)
    	{
    		if (CanCrouch())
    		{
    			CharacterMovement->bWantsToCrouch = true;
    			bIsCrouched = true;
    		}
    	}
    	else if (!CharacterMovement->CanEverCrouch())
    	{
    		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, TEXT("We are trying to crouch"));
    	}
	
}

Can anyone give me some insight as to what I’m doing wrong?

Thanks.

You shouldn’t set “bIsCrouched = true;”, because then when the actual crouch code runs it will think there is nothing to do because it’s already crouched.

(sorry I didn’t see this thread earlier, I noticed it’s quite old, but hopefully this response will help other people).