Download

Blueprint steals input from pawn base class

So after experimenting with how to best migrate some of my blueprint functionality to C++ I’ve across this seemingly basic issue of where to handle input. Ideally I would like to be able to continue handling input in the BP for prototyping as well as in C++ for processing the more heavy stuff.

After readingthis golden Wiki article (thanks Rama!) I find this very elegant and would like to do it this way. So basically handle the input in the pawn base class which the BP inherits from and then remove the direct input handling from the BP and instead handle events raised in C++.

So basically in the MyPawn.h


	UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "Move Forward"))
	virtual void MoveForward(const float& Value);

...

protected:

	void SetupPlayerInputComponent(UInputComponent* InputComponent) override;

	void OnMoveForward(float Value);

and MyPawn.cpp


void MyPawn::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
	check(InputComponent);
	
	InputComponent->BindAxis("MoveForward", this, &MyPawn::OnMoveForward);
}

...

void MyPawn::OnMoveForward(float Value)
{
	this->MoveForward(Value);
}

The input is being handled fine in the the base class as long as I use it directly as Default Pawn in the GameMode, but as soon as I use my BP which inherits from this pawn, the input is being stolen by the BP. Even if I remove all input nodes, heck, even if I use a completely empty BP, the input is stolen. Tried to find a BP setting to perhaps rectify the issue but to no avail.

Long story short, how do you guys handle this stuff?