Good practice with Controller and Pawn?

Hi,

I was curious as to what is considered good practice when it comes to dividing responsibilities between the Controller and the Pawn. Also, the “game handler”, if you make one.

For example, handling death. Let’s say your player avatar dies and gets destroyed when he touches X.

  • Should that collision be handled in the controller or the pawn?
  • Should the death event and the destruction of the pawn be handled by the controller or the pawn?
  • …If the pawn, should the controller handle spawning a new avatar pawn, or should that be deal with by a “game handler”?

That’s just an example. But overall, how “should” things be divided?

Thanks,

In Unreal (all versions of the engine), the Pawn is an Actor that is the representation of the character in the game world. The Controller is basically its brain, and even though it is an actor too it usually does not interact with the rest of the world directly.

So what I’ve always done (and told other people to do) in Unreal projects is to make the Pawn handle everything that happens to the character in the world, whereas behaviour is for the Controller. Depending on your project, the dependencies between certain types of Pawns and Controllers can be pretty strong though.

So for your examples :

  • Collision is definitely handled by the Pawn
  • Death typically happens to the Pawn first (through TakeDamage, etc.), but the Controller is obviously involved in the process too after that.
  • Management of Pawn spawning is more is game-specific, it depends on what you want to achieve…