How to override and manually spawn a PlayerController?

Hello,

Is there a way in Blueprints to override an existing event/function (probably in GameMode?) that spawns a PlayerController when a player joins the game session?

Currently, in my GameMode.OnPostLogin override event when the player logs in to the game session I:

  1. Cast the PlayerController instance parameter that UE4 passes as a parameter to the OnPostLogin event to my CameraPawnController.
  2. Assign the PlayerController to a team.
  3. Manually spawn a CameraPawn.
  4. Possess the newly spawned CameraPawn with the CameraPawnController.

I need the ability to intercept/inject my own code into the PlayerController spawning process so I can pass in some parameters on spawn (variables marked as Private, Expose on Spawn, Editable) to the PlayerController in order to address race conditions I am running into with PlayerController.OnBeginPlay.

(Not an expert but…)
You can’t destroy a PlayerController, since this is the “soul” of the player, that connects it with your game. However you can (as you wrote if I understand well) destroy it’s pawn and make it possess another one. I think you should make a custom event in the PC, with the name “InitialSetup” for example, and pass all the information that you need with this after the OnPostLogin event. Maybe the whole BeginPlay chain should be connected to here instead. But actually if I know well (but don’t believe me without test), after the 1st PC, the others don’t have their Pawn yet spawned when the OnPostLogin is called. And also every PC’s BeginPlay event is called later than the OnPostLogin, so if you can pass the info to them then let the BeginPlay do the hard work, if you insist.

And also every PC’s BeginPlay event is
called later than the OnPostLogin, so
if you can pass the info to them then
let the BeginPlay do the hard work, if
you insist.

Actually I experimented with this last night. The PlayerController.BeginPlay is called on the server and then followed by GameMode.OnPostLogin and finally PlayerController.BeginPlay is called on the client.

Oh, then it’s the same as the pawn creation. Still I would use an Initial setup event, and let it call everything you need, instead of the begin play.

And also, probably those variables should be stored in the PlayerState, so not only the client could reach it.