Download

Getting back into UE- Character vs Controller

I know this gets asked fairly regularly, but after having had to take a long break, I’m just now coming back to UE. Even before, I’d had issue with when to use the controller classes, so I wanted to see if I understood it better, after having looked through docs and comments again:

Say I have a CharacterPawn. It contains all information relevant to the character, itself, e.g. mesh, HP, maybe a list of attacks, etc. Nothing specifically about controls, though it may contain information that is relevant when being controlled, like walk speed.
In one instance of gameplay, I’d like players to control the character. In this case, I’d possess it with a PlayerController, which contains the actual interface for the player moving the character back and forth when pressing directional buttons, attacking on attack button presses, jumping, whatever.
In another instance, I’d like the character to just be ambiently walking around while the player does other things. In this case, I’d possess it with an AiController, which tells the character to move around automatically, without player input, using an assigned blackboard/behavior tree.
Same character, possessed by two different controllers depending on the situation.

Is this proper usage?

Yes.

  • character: thing with a mesh that can be moved around
  • playerController: the player’s (or AI) intent

Controller is the brain, Character is the object.

The character should contain the input bindings for things like walking, running, mouse look etc. You can ‘Unpossess’ and ‘Possess’ characters with different controllers if required.

Players will (usually) always have a player controller, an AI is a player controller and nothing else. All AI commands are run through the controller, which works out how to then ‘move’ it’s character.