So recently I have been working on some code and I did the same type of setup in two places and I get different results. This is in regards to binding input events for actors in C++. So, in BeginPlay I do the following:
Now when I did something like this in the TopDown C++ code template, it worked perfectly, no issues. Now in a Blank project with minimal C++ setup, it does not work and I have to trigger the event in Blueprints. Not a huge deal, but it is not working as designed. is the DefaultInput.ini file:
According to the docs, an Actor can be pushed onto the input stack. And the SetupPlayerInputComponent(class UInputComponent* InputComponent) method is only called when possessed by a PlayerController, according to the docs.
Is identical functionality. Controller->GetPawn()->GetController() is just going to be Controller.
Ok … sorry. Now back on topic. In general your setup looks sound. When you’re in game you can also do a console command “showdebug input” which will display the current input stack. The most common cause of something like this would be that something else is consuming the key press before it makes it to your Actor.
The second idea is that the BeginPlay on the Paddle is somehow happening before APlayerController::InitInputSystem is getting called and so the input stack is getting cleared. If you have full code you could put a breakpoint at the point you push your component on to the stack and inside InitInputSystem and be sure it isn’t getting called in an unfortunate order.
Thanks for the suggestion. I will look into it when I can get back to that project and post on what was happening for anybody else who might run into this issue.
In a reply I said I would give your suggestion a whirl. It seems to only be an issue with action bindings. Axis bindings work fine. I came across the same issue in a new project as well. During debug breaks I can see that the size of objects on the stack is 4 for my action bindings (2 actions each of 2 objects). But showing input debug displays only 3 objects on the stack, missing my 2 actors and/or pawns.