Cannot check if a certain key is down



float result = InputComponent->GetAxisKeyValue(EKeys::A);
if ( result){		
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("This is an on screen message!"));
}

I have that in my Tick function. The tick function actually gets called, but apparently there is something wrong with the above code. I tried other keys, but still nothing.

An input component itself does nothing unless it is enabled and added to the player input ‘stack’.
This gets processed by the player input class, which itself is called from the player controller.

Check out: https://docs.unrealengine.com/latest/INT/Programming/Gameplay/Framework/Input/index.html

So the question is, which tick function?
Actor? Pawn? PlayerController? Other?

For example, detecting the key input from a Pawn, you could do:



if (APlayerController* PC = Cast<APlayerController>(Controller))
{
    if (PC->InputKeyDown(EKeys::A))
    {
        GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("This is an on screen message!"));
    }
}


I have the UInputComponent I receive at the SetupPlayerInputComponent override for my class which inherits from ACharacter.
That being so, the Tick function is from an Actor, since Character inherits from it.

Actor => Pawn => Character => YourCharacter?



void AYourCharacter::Tick()
{
    ...


As long as your actor/pawn/character has a controller that is also a player controller, using the PC->InputKeyDown() should work.
If not, nada.

well thats the class hierarchy right there…

Without seeing the code in context, I’m unsure what is going on :frowning:

Did the answer to your question on the answer HUB not resolve this?