I would like to know if it is possible to bind input events to functions in my C++ Actor class. Similarly to the functionality that is provided in the pawn class with SetupPlayerInputComponent. I’ve looked around everywhere as far as I know for a solution to this and the only thing I’ve found is this: Bind input in custom Actor - C++ - Unreal Engine Forums which ends up not working for me. The test I made with the solution from the thread is the following code:
InputComponent = NewObject<UInputComponent>(this);
InputComponent->bBlockInput = bBlockInput;
if (InputComponent)
{
InputComponent->BindAction("MouseClick", EInputEvent::IE_Released, this, &ApaddleClass::clickRelease);
InputComponent->BindAction("MouseClick", EInputEvent::IE_Pressed, this, &ApaddleClass::clickOpen);
EnableInput(Cast<APlayerController>(GetOwner()));
}
All of that is in my BeginPlay() function. What ends up happening is the ClickOpen() and ClickReleased() functions never get fired.
Just as a side note: I have two of the same actor present within my scene and if I understand it correctly, or at least what I want to happen is the ClickOpen() and ClickReleased() functions to get fired for all of the same actor present withing my scene whenever I click anywhere in my scene.
I know I can use the OnClicked() and OnReleased() delegates from a collision component and bind my functions to those, but I’ve already done that and that works. However, it doesn’t give the effect I want in that if I release the mouse click and the cursor is not over the collision component, the OnReleased() delegate function will not fire. I want that function to fire no matter if my mouse cursor is within the bounds of the collision component or not which is why I’m trying to find out how I can bind input events to functions.
Just to summarize the solution I’m looking for. I’m basically looking for a way to detect mouse clicks and releases no matter where I click or release.