Hello & Thanks for the continual support here!
Having a kaniption fit with code… i’m trying to do what i’ve done in the past for several other projects - somethign i’ve learned and adapted from both Mike Allars Generic Shooter template & Multiplayer Shootout for spawning characters of remote clients in the GameMode from AGameMode::PostLogin(InController).
Below is the code - simply put though if I use this method from a class that inherits of AGameMode - my pawn is possessed but any CLIENT role is unable to process input… and any cast to PlayerController is therefore failing.
If I use the SAME EXACT CODE - but inherit from AGameModeBase - this works perfectly fine for remote clients and they are allowed input - the controller casts succesfully and life is a happy world.
What is the underlying problem here? I dont know how to correct it - i’ve even passed through the controller from PostLogin to all other handling code - all the way to the point of pawn possession… and its still acting like this.
AGameMode/AGameModeBase
void AAvantGardeGameMode::PostLogin(APlayerController* NewPlayer)
{
Super::PostLogin(NewPlayer);
if (NewPlayer && HasAuthority())
{
AAvantGardeGameState* MyGameState = Cast<AAvantGardeGameState>(GameState);
AAvantGardePlayerState* PState = Cast<AAvantGardePlayerState>(NewPlayer->PlayerState);
if (PState && MyGameState)
{
uint8 NumTeamA = MyGameState->TeamA.Num();
uint8 NumTeamB = MyGameState->TeamB.Num();
if (NumTeamA > NumTeamB)
{
PState->TeamB = true;
MyGameState->TeamB.Add(PState);
}
else
{
PState->TeamB = false;
MyGameState->TeamA.Add(PState);
}
RespawnPlayerRequest(NewPlayer, DefaultPawnClass, PState->PlayerName);
APController_Game* PController = Cast<APController_Game>(NewPlayer);
if (PController)
PController->Client_PostLogin();
}
}
}
void AAvantGardeGameMode::RespawnPlayerRequest(APlayerController* InController, TSubclassOf<APawn> InCharType, const FString &InPlayersName)
{
if (InController->GetPawn())
InController->GetPawn()->Destroy();
UWorld* const World = GetWorld();
FActorSpawnParameters SpawnInfo;
SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
AActor* TeamSpawner = ChoosePlayerStart(InController);
AAvantGardeCharacter* SpawnChar = World->SpawnActor<AAvantGardeCharacter>(InCharType, TeamSpawner->GetTransform(), SpawnInfo);
if (SpawnChar)
{
InController->Possess(SpawnChar);
SpawnChar->SetOwner(InController);
InController->ServerChangeName(InPlayersName);
}
}