Download

UWorld::SpawnActor spawns multiple actors in PIE mode

Hello folks,

I’m rather new to the Unreal, please bear with me a little.

About my problem: I’m currently implementing some kind of character creation.

  1. Connect using username/password as URL options from main menu widget
  2. ACustomGameMode::PreLogin() approves login by validating credentials
  3. Some widgets are created by the ACustomPlayerController(), character customisation happens.
  4. Widget calls ACustomPlayerController::CreateCharacter();

ACustomPlayerController.h



UFUNCTION(Server, Reliable, BlueprintCallable)
void CreateCharacter();




void ACustomPlayerController::CreateCharacter_Implementation()
{
    ACustomCharacter* char = GetWorld()->SpawnActor<ACustomCharacter>(some blueprint class);
    SetPawn(char);
    Possess(char);
}


Now, in PIE mode, two characters are spawned.

ACustomGameMode does’n specify a DefaultPawn class, so no pawn is spawned by default.

I’ve had a closer glance at the Runtime code of UE4, and it seems like I’m doing pretty much the same the UE4 AGameMode::RestartPlayer() code would do.