CreatePlayer does not always spawn pawn

Hi,

I’ve done some testing with a small local multiplayer game. I spawn my second playable pawn via my C++ GameMode:

void ABrawlMode::BeginPlay()
{
	Super::BeginPlay();


	for (int32 i = 0; i < 1; i++)
	{
		UGameplayStatics::CreatePlayer(this, -1, true);
	}
}

To my understanding this should spawn a second playercontroller with it’s pawn, if there are enough free player starts of course. However it does not always spawn the pawn. Sometimes I’m left with only 1 pawn created, but the second controller (including hud, playerstate, etc) is always created. It is just the pawn that is missing sometimes. I already tried to override these methods, but without any effect regarding this issue:

	/** select best spawn point for player */
	virtual AActor* ChoosePlayerStart_Implementation(AController* Player) override;

	/** always pick new random spawn */
	virtual bool ShouldSpawnAtStartSpot(AController* Player) override;

	/** check if player can use spawnpoint */
	virtual bool IsSpawnpointAllowed(APlayerStart* SpawnPoint, AController* Player) const;

	/** check if player should use spawnpoint */
	virtual bool IsSpawnpointPreferred(APlayerStart* SpawnPoint, AController* Player) const;

I did notice that when only one pawn is spawned, the second controller does have another component attached, which the first one does not have. However I don’t know what this means (referring to: PC_InactiveStateInput…)

http://puu.sh/m2GP2/bc081d7543.jpg

Can someone enlight me what I might be doing wrong?

Cheers

Maybe check the logs, sometimes engine informs about problems there, SpawnActor function if fails always print reason why in log, Window->Devlopment Tools->Output Log

Thanks ,

you were right. There was an error message saying that there is a problem with the collison. But I really can’t imagine why to be honest. I do experience the same problem in another project where only 1 player is spawned.

http://puu.sh/m3NtO/4a7f935ac1.png

Ok it was a problem with the collision. Both players sometimes wanted to spawn on the same spot.
I actually had overriden the “ChoosePlayerStart_Implementation” and adapted the way it’s done in the shooter example. But I forgot that all these collison checks at the spawn point were done with characters. So my defaultpawn was casted to a character and then the collision tests were made. Too bad that my pawn is actually a pawn and not a character, so all these tests failed. I’ve now written a test tailored for my very own player class. It now works.
Thanks again for getting me on the right track.

Cheers