BindAxis question

Hi all,

I have a very simple C++ class that extends APlayerController, where I have the following call

UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("Desiner_MoveForward", EKeys::W, 1.f));
InputComponent->BindAxis("Desiner_MoveForward", this, &ADesignerController::MoveUp);

The MoveUp function is defined as follows in the header:

UFUNCTION(BlueprintCallable, Category="Designer")
virtual void MoveUp(float Value);

Everything compiles and runs fine.

In the editor if I test the game, I notice that the MoveUp function is being executed continuously.

Furthermore, if I create a Blueprint class that subclasses this C++ class and open the Blueprint editor then the method also begins executing.

Just want to check if this is expected behaviour in both cases?



This is the expected behavior. Because you’re using an axis mapping the function is constantly triggering and checking for the float value of the axis. The behavior of the function should be tied to the value such that if the axis value is 0 there is no input. This is why axis mapping is ideal for movement input. If you only want MoveUp to trigger once when pressed you then you would want to use an action mapping instead.


Doug Wilson

Thanks Doug!