UGameplayStatics::CreatePlayer Not Working in C++

Simple as that. If i try to call it from the Blueprint Editor it works, But if i try to call from c++ using the following code from my custom C++ Game Mode:

for (int PlayerId = 1; PlayerId < NumberOfPlayers; PlayerId++)
{
// Instantiate the new Controller.
APlayerController* NewPlayer = UGameplayStatics::CreatePlayer(GetWorld(), PlayerId, false);
}

It doesn’t do anything.

If that wasn’t enough the only workaround i found is creating a blueprint native event to call the Blueprint Node Create Player.

Hello LuLima,

Could you please provide the full code for your Game Mode class?

Can i have your forum link for me to private message you?
If a change the false from:
APlayerController* NewPlayer = UGameplayStatics::CreatePlayer(GetWorld(), PlayerId, false);
to true…
APlayerController* NewPlayer = UGameplayStatics::CreatePlayer(GetWorld(), PlayerId, true);
it started working…

When you set it to true, it will spawn the pawn that is attached to that player, which would explain why it would work when you made that change.

What was the expected behavior when you had it set to false?

Since you seem to have resolved your issue, there is no need to provide the code at this time.

I wanted to spawn just the controller with no pawn. In a second moment i would determine which pawn it will be. Is this a expected behaviour for the function call?

I can perform some additional tests. Actually, go ahead and send me the code that you’re using so I can reproduce it on our end and then determine if there is an issue. Here is the forum link where you can send me a PM: https://forums.unrealengine.com/member.php?160394-Sean-Flint

Thank you