I am trying to make a prototype for new game
My game has 3 different characters, they are all placed in the world and you can switch between them by pressing tab
I am not sure how will i handle the input.
I can create 3 player controllers, each per character and implementing the tab logic in each one of them
I can create 1 player controller which pass the input to the selected character
The first solution is ok but i will have code duplication at each one of the player controller of the switching characters logic
The second solution solves it but it sounds like it is not the way i am supposed to to this
What is the best way here? it there a third way that i am missing?
The PlayerController would still have to switch control between characters but each character could have different input if necessary. Shared input actions could be inherited from a character base class.
Having 3 PlayerControllers would not be needed as you would simple possess one character at a time with the same PlayerController.
Isn’t that what the possession system is for? The whole point of the controller -> pawn relationship is to have a simple system for switching what pawn is controlled by a given player/ai controller. Just call PlayerController::Posses(TargetPawn).