Simple Input issues

I’m surprised that I am again finding something that is so simple so difficult to get working. I was hoping some basic input (Like Key X is pressed) would come as a simple structure for the engine, even part of the GEngine class or something but it seems not?

So I decided to have a dig around in the documentation and forums and found the FPS tutorial which showed me how to get a simple input working in code. However, I have tried to add this method to a previous project and I just can’t seem to get it working.

I created a character class which does some things like create some spheres and set their positions and that all seems to work, however when I press down on a key, it just doesn’t seem to register it at all.



// header file
protected:
	virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) OVERRIDE;

	UFUNCTION(BlueprintCallable, Category = "InputControls")
		void DeleteAllBalls();

// .cpp file
void AInputControls::SetupPlayerInputComponent(UInputComponent* InputComponent)
{
	// set up gameplay key bindings
	check(InputComponent);
	if (InputComponent != NULL)
	{
		InputComponent->BindAction("Test", IE_Pressed, this, &AInputControls::DeleteAllBalls);
	}
}

void AInputControls::DeleteAllBalls( )
{
	m_ballManager->DeleteAllBalls();
}


I have setup the Action ‘Test’ in the project settings but for the life of me I can’t seem to get it to work. Am I missing something obvious that needs to be ticked to allow input or is there a more simple way to check in code if a key, for example ‘X’ has been pressed?

I use same method and it works fine and its easy to use once you know priciples of UE. 2 quastions.

Did you attached InputComponent in to your actor? Its not part of actor by default
Did you pushed poiter to InputComponent of that actor to PlayerControler of player which should control that Actor?

My class that sets up the input component is a “class AInputControls : public ACharacter”. I thought the character already has the Input component attached as I am able to override the SetupPlayerInputComponent function? All I am trying to do is check whether a button has been pressed somewhere in the code and I thought the character class would give me the best base class to approach this?

Ok looks like we do think little diffrely, according to tutorial you follow:

Did you make your PlayerController posses the Actor with Possess(APawn* aPawn) function?