Need help with understanding C++ input binding

Hi there. I created my first C++ first person template and I really don’t understand how input binding works in there. As you know we have a piece of code for inputs in character child class:

void AMyGame::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
	// Set up gameplay key bindings
	PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
	PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);

and another piece for jump:

void AMyGame::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)

void AMyGame::TouchStopped(ETouchIndex::Type FingerIndex, FVector Location)

and this is the Jump function defined in ACharacter class:

void ACharacter::Jump()
	bPressedJump = true;
	JumpKeyHoldTime = 0.0f;

void ACharacter::StopJumping()
	bPressedJump = false;

So my question is what really makes my character jump?
If I want a set of condition before movements where should I do that? For example if character is in a certain region I want to disable the movements only. So where can I setup things like that?
It’s a pretty long question so thank you in advance.

Most likely, the functions for jump would be virtual. Which means you can override them in your character subclass. So in the case that you want to prevent the jump in certain situations you would declare the jump function in your subclass like this.

virtual void Jump() override;

Then specify an exit condition in the jump function before calling the parent class function.


Void AYourCharacter::Jump()
     if(YourTestCondition == false) return;


The test condition will be specific to your game so you will have to decide what the scenario is to prevent jumping.

Yeah, it makes sense. let me try and report the result here. thank you

Works like a charm.

Awesome! Good luck on your game!