Download

Switchable possession between multiple characters (Design question)

Hey everyone, I have a bit of a design question.

In my game the player is able to control one of 4 characters and switch between them. I know how to do that, but I don’t know how I should design the system.
The options I’ve considered are:

  1. Create some sort of (invisible) actor that just stores which character the player is controlling.
  2. Possess the character the player wants to control and just leave it at that.
  3. Do the same as 1 but in the Game Mode BP

In Unity I’d go with the first option, but UE4 has so many more features so I thought there might be another option.

Keep in mind that later I’ll need UI and other systems to get information about the controlled character. In situation 1 and 3 I’d just access whichever BP is in charge of knowing which character is being controlled (Game Mode or an invisible Actor) and get a reference to the controlled character. In situation 2, however, I would have a function library function to loop through all Actors that are controllable and return the one that is currently possessed.

I want to know what would be the best way to do this, the more organized and flexible way. Basically a centralized system (1 and 3) vs a decentralized system (2).

Thank you very much for your help!

I made prototype of multiplayer squad based game.

Best solution was making player pawn just camera, and player controller had only mouse to snap camera to pawns on map, and then take control over them.

All actual soldiers and characters were AI driven puppets. When i snapped my camera (and controller) to pawn i sent direct orders (even joked a lot about "assuming control) over to pawn, like what direction to face, where to go.

This was simplest way of coding 4 soldier squad game mode in unreal. It also has huge advantage you have same pawn for AI bots and player, when player leaves pawn you assign normal AI controller to it. Same code for player pawns an ai pawns, just posses/unposses.