Server: remote PlayerController.BeginPlay executed before GameMode.Login?

This is somehow related to: GameMode: local player controller Login/PostLogin called before BeginPlay? - Blueprint - Unreal Engine Forums (UE-27284)

It seems that on the server, when a client connects to the server, the server side corresponding PlayerController.BeginPlay is executed before GameMode.Login for the same PlayerController, while I assumed that the remote PlayerController.BeginPlay should be executed after GameMode.Login for the same PlayerController?

I wanted to perform some early association inside GameMode.Login for the remote PlayerController, and hoping that when PlayerController.BeginPlay is executed, it has the association and can do some more work. The same expectation is true for the local PlayerController (the local player) - i.e. for local PlayerController, GameMode.Login is executed before PlayerController.BeginPlay, as expected.

Is the behavior for remote PlayerController at fault here?

It seems that the local PlayerController.BeginPlay() is delayed until the world has begun play, which makes it after AGameMode::Login is executed — the PlayerController is created right inside though, but since the world hasn’t begun play while creating the local player, the just created PlayerController won’t invoke its BeginPlay function, but later.

Remote PlayerControllers, however, when getting logged in, the world has most probably begun play, so its BeginPlay() function will be invoked immediately during PlayerController construction. And since I did override AGameMode::Login function, and added some logic with/after the newly created player controller, so the remote PlayerController.BeginPlay() appears to be executed before my custom logic after Super::Login is executed.

But, it still seems more reasonable that APlayerController::BeginPlay should be invoked after PostLogin, and the current behavior of controller begin play seems to be too early - BeginPlay should be considered a safe place that BP scripting should assume that it is after all the low level setup, right?

Hey Iluo-

I’m somewhat unclear what exactly you’re reporting. Are you saying that the PlayerController::BeginPlay() is called before GameMode::BeginPlay() when it shouldn’t be? What is the relation to GameMode::Login()? Can you list the order of events as you see them happening and the order you believe they should occur in?

Cheers

I’m under the impression that the game mode only exists on the server, right? So the game mode’s begin play will always trigger before any client’s remote events since there couldn’t possibly be any connected clients at that point.

If that’s not the issue, then I too am not quite understanding what you’re reporting.

Hi Iluo,

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.

Thank you.