I’m trying to listen to Input in PlayerController, similarly to how it was done in Character.
However it seems like it works differently, there’s no function similar to Character::SetupPlayerInputComponent, and I see there’s this function: Controller::PushInputComponent
The build itself is successful and it works for custom actions I make (e.g. attack), but any function related to BindAxis that is called from the controller causes in UE crashing.
The functions in TestCharacter remained untouched, they were just made public.
My speculation is that the input in the character is processed after the input in controller, possibly after some function that is crucial for the calculations to work.
So when I call functions that were normally supposed to be called when the character input is processed, when the controller input is processed, UE crashes as something is missing for it to work.
Have you tried debugging where it crashed? My best guess from your code is that P is NULL either because the axis is beig processed before tick or that the player controller handles input at a point where it isn’t controlling a pawn. I’d just call GetControlledPawn in each function and check it for NULL and see if that resolves your crash.
It is more that Axis delegates are called every frame with a value of 0 if there is currently no input which could occur before the Pawn exists. Actions, on the other hand, only get called when you press the button so that won’t happen until you’re finished spawning in to the level and the controlled Pawn is fully valid.