Enabling Crouching in C++

Hi folks,

I have already created my crouching functionality in Unreal (which is not rocket science) but I am struggling to find a way to enable crouching within C++

Of course, you can easily tick the (Can Crouch) box within the character blueprint (Character Movement> Nav Movement> Movement Capabilities> Can Crouch). However, I looked through the documentation for how to implement this within C++ and on the web and I can’t find anything helpful.

The “CharacterMovementComponent.h” library only has a couple of functions: CanEverCrouch() or CanCrouch() but they only return the boolean as opposed to setting it.

Help will be much appreciated.

Just call Crouch and UnCrouch on your character.

Note: This only shrinks the capsule component, you will have to do everything else like animation transitions yourself using this information.

void ATPCPPCharacter::CrouchTest()
	if (bIsCrouched)
		UE_LOG(LogTemp, Warning, TEXT("UnCrouching"))
		UE_LOG(LogTemp, Warning, TEXT("Crouching"))


1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms