Download

Handling Input- the right and wrong way

Apologies for another beginner question. I’ve seen several questions about whether to handle input in the controller or the character several times, but also seen several different answers. Some answers I’ve seen include:

  1. Handling input in the pawn, using the controller mainly as a means of keeping important, persistant information, like score.
  2. Handling input in the controller, differentiating between potentially different control schemes via an event or variable.
  3. Handling potentially different input via different, multiple controllers, switching between them, as needed.
  4. Making a standard controller that just passes input information to whatever pawn is being controlled, letting the pawn interpret the input as it likes.

Which of these is the “right” way, or is there even a right way? Are all these valid approaches, depending on game needs? 1 makes the most sense to me and is how I did things before, but I always see a “good for simple controls” asterisk next to it in answers.

Although you could store score in the controller it would make more sense to store it in PlayerState. You should look at the controller as the will of the player. Things like UI may be handled directly through the controller as it has no Pawn to act on unless if it is Pawn specific. If you want to temporary block input it often makes sense to cut it in the source being the Controller so you don’t have to handle it on every Pawn.

I would go with a mix of 2 and 4 where the controller handles the source input and the Pawn gets an Event from the Controller and the Pawn knows what to do with it.

Great, that reaffirms what I wanted to go ahead with and try, then. Thanks for the response!