I’m calling UGameplayStatics::CreatePlayer to create a second local player. I can confirm from the World Outliner that a second player controller is created, together with all supporting classes (PlayerState, Pawn, etc.).
At the Controller BeginPlay, in the Blueprint, I’m calling CreateUserWidget to create the UI for the player. At that point I get an error: “CreateWidget cannot be used on Player Controller with no attached player”.
Shouldn’t this be done by default? I’ve, alternatively, called CreatePlayer from the GameMode blueprint, but the result is the same.
else if (!OwnerPC.Player)
{
const FText FormatPattern = LOCTEXT("NoPlayer", "CreateWidget cannot be used on Player Controller with no attached player. {PlayerController} has no Player attached.");
FFormatNamedArguments FormatPatternArgs;
FormatPatternArgs.Add(TEXT("PlayerController"), FText::FromName(OwnerPC.GetFName()));
FMessageLog("PIE").Error(FText::Format(FormatPattern, FormatPatternArgs));
}
Now, this means that the PlayerController doesn’t have a Player. But, I’m creating a PC through GameStatics: