I’m working on simply setting up some basic variables inside the controller during possession that are only needed to be known by the owning client of a custom controller. In my attempt to do this, the functions Possess() on a Controller and PossessedBy() on a Pawn are the perfect place to initialize these settings.
However! Not all is well during the possession, it seems that when a client starts up at the beginning of the game, they receive their controller as PlayerController_0, which is what’s passed through during all the possession functions for both Pawn and Controller. Afterwards, PlayerController_0 disappears from all knowledge and is replaced by PlayerController_1 which doesn’t seem to transfer over settings from PlayerController_0 for the client, and no new Possession chain is called.
This is painful, as I can’t exactly set my variables now without a workaround due to the out of sync possession, is there anyone who can explain to me what I’m missing?
BLTPlayerController.cpp
void ABLTPlayerController::Possess(class APawn* inPawn)
{
Super::Possess(inPawn);
UE_LOG(LogPC, All, TEXT("=== ABLTPlayerController ==="));
UE_LOG(LogPC, All, TEXT("%s"), *GetName());
UE_LOG(LogPC, All, TEXT("inPawn = %s"), *inPawn->GetName());
//Just gives us a reference to our own specific custom pawn so we don't have to constantly cast
ADebugFunctions::LogNetworkRoles(inPawn);
Test(inPawn);
}
void ABLTPlayerController::Test(APawn* inPawn)
{
UE_LOG(LogPC, All, TEXT("Currently: %s"), *GetName());
CharacterPawn = Cast<ABLTPlayerPawn>(inPawn);
TestPawn = inPawn;
}
Here is a photo of the log that shows it starting off as PlayerController_0 and setting variables, then becoming PlayerController_1 afterwards with no sign of the original PlayerController_0