Add Crouch and Jump

Hello guys,
I am trying to add crouch and jump to the game system, sadly with no luck. I’m testing the BP directly (although I’d prefer to use c ++ like the rest of the project) post photos of what I’ve done so far:

5




At the moment the jump works, but the crouch doesn’t seem to take the value.

Well you don’t have Set isCrouch plugged in.

You mean in bp animation graph? if yes how i can connect it? because true(into branch) it’s just for one pin at time.

Ok i finnaly did it :sweat_smile:

First of all i use c++ instead of BP like:

Header:

#include "GameFramework/CharacterMovementComponent.h"
//..other code
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, category = "animation")
		bool eSeduto; //is crouch
//other code
private:
    void isCrouch();

CPP:

// Called to bind functionality to input
void APrincipalePersonaggio::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);

	//... other  inputs
	PlayerInputComponent->BindAction(TEXT("toggleCrouch"), EInputEvent::IE_Pressed, this, &APrincipalePersonaggio::isCrouch);
}

void APrincipalePersonaggio::isCrouch()
{
	if (GetCharacterMovement()->IsCrouching())
	{
		UnCrouch();
		eSeduto = false;
	}
	else
	{
		Crouch();		
		GetCharacterMovement()->GetNavAgentPropertiesRef().bCanCrouch = true;
		eSeduto = true;

	}
}

In BP:

Hoping it will be useful to someone I wish you a good day :slight_smile:

1 Like

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

Privacy & Terms