Download

GetPawnIterator

Hi all,
In my network game (which I’m testing using the run in editor feature), I am only getting one Pawn when I try to iterate the list of players using either:

GetWorld()->GetPlayerControllerIterator()
or
GetWorld()->GetPawnIterator()

I call these in the BeginPlay() of my GameMode. The game is running fine with several emulated clients, so I was expecting to be able to iterate over each of those players.

Any clues?
Cheers

You are using them in a loop?

for(FConstPawnIterator Iterator = World->GetPawnIterator(); Iterator; ++Iterator)

Yes, exactly like that.

Its really difficult to know without seeing the code but since that simple one is ruled out I might lean towards the fact that the Controllers/Pawns have not been Spawned that early yet in the GameMode. Have you tried iterating the list during actual gameplay, like during MatchStart or some other GameMode method like tick that runs more often? You can use* GetPlayerCharacter(UObject* WorldContextObject, int32 PlayerIndex);* to iterate over until you find null if youre looking for an alternative if you think there is something wrong with the default iterator :cool: