Why the function test be call repeatedly?

I want to handle input events from keyboard by PlayerController like this:

void AMyPlayerController::SetupInputComponent()

    InputComponent->BindAxis("VerticalMove", this, &AMyPlayerController::verticalMove);

void AMyPlayerController::verticalMove(float v)
    GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, "test");

But the function verticalMove be called repeatedly when nothing keys be pressed.
Anybody know why?

Hey Tancen,

This is because the “Axis” function that you bind to is called every frame, it is designed to constantly read the value of an axis, like a joystick, or a trigger, or even just forward and back buttons.

If you print the “v” value in your verticalMove function, you’ll notice that it reports 0 when you don’t have any keys pressed down, and then changes when you press one of the keys attached to that axis.

This is the intended functionality, if you want key-down and key-up style events, you’ll need to bind to something else (I’m not totally sure right now what those events are)

It is IE_Pressed and IE_Released. IE_Repeat is when the action event key is held down.

Oh, and welcome!

Thanks for