I started of with the ThirdPerson template and all inputs are handled in the Character class under SetupPlayerInputComponent
Is this the place where all of my inputs should be handled? What if I want to change some variable in the PlayerController based on some inputs?
I can’t access the the PlayerController from a Character because it is just a Controller. I also tried to bind some inputs in the PlayerController itself like this
I think as long as you have the 1-1 relationship between controller and actor you can do it this way. But let’s think about an 1-n relationship where a controller controls an camera-actor and can also select n other actors which may represents units in a RTS Game.
I see two possible solutions: Handle the input in the PlayerController or handle the input in the pawn. My first solution would handle the input in the controller but store properties like selected actors in the pawn.
But maybe there are other suggestions and experiences?
I was also trying to get the PlayerController to handle the input. I figured that would be the best place to process inputs that were not specific to a Character, but I was having the same problems with a runtime error in SetupInputComponent. I think that the issue is that InputComponent is not automatically initialized to anything, you have to create a UInputComponent object for it. I found some sample code in the Pawn class, that I suspect might be getting called by the engine to generate the InputComponent that is passed into the Character’s SetupPlayerInputComponent. I initialized the InputComponent pointer like this:
I think we’re researching on similar topics. I have been unable to find a best path for implementing a player controller input. One requirement on mine is that the input needs to handle absolute coordinates and translate those to the PlayerController. Though this sounds simple, in theory, I haven’t been able to find a suitable answer yet.