Pawn not in the iterator list in clients when start points are distant

domzorg
Mon, 27 Aug 2018 13:57:30 +0000
Multiplayer & Networking

I have a strange behavior with clients connected on a dedicated server.

I have two different maps with start points.

Map5 where the start points (circles in the image map5.png) are placed very close one from the other.

In this map, when the players (two clients) are spawned at start point, the client can see all pawns using the code below from the PlayerState.

		for (FConstPawnIterator Iterator = GetWorld()->GetPawnIterator(); Iterator; ++Iterator)
		{
			APawn* Pawn = Cast<APawn>(*Iterator);
			AKPlayerCharacter* Char = Cast<AKPlayerCharacter>(*Iterator);
			UE_LOG(LogKSGMState, VeryVerbose, TEXT("AKCharacterState::GetPlayerCharacter  -  iterator Pawn=%s  Char=%s    Char->PlayerState=%s"), *GetNameSafe(Pawn), *GetNameSafe(Char), (Char != NULL) ? *GetNameSafe(Char->PlayerState) : TEXT("NULL"));
			if (Char != NULL && Char->PlayerState == this && !Char->IsDead())
			{
				CachedCharacter = Char;
				UE_LOG(LogKSGMState, VeryVerbose, TEXT("AKCharacterState::GetPlayerCharacter  -  Found Char=%s    assigned to CachedCharacter"), *GetNameSafe(Char));
				return Char;
			}
		}

In the client log, I can see the two players
[2018.08.27-13.52.10:296][962]LogKSGMState: VeryVerbose: AKCharacterState::GetPlayerCharacter - this=KCharacterState_1 CachedCharacter=None GetOwner()=None GetWorld()=T-Map5
[2018.08.27-13.52.10:296][962]LogKSGMState: VeryVerbose: AKCharacterState::GetPlayerCharacter - iterator Pawn=BP_PlayerCharacter_C_0 Char=BP_PlayerCharacter_C_0 Char->PlayerState=KCharacterState_0
[2018.08.27-13.52.10:296][962]LogKSGMState: VeryVerbose: AKCharacterState::GetPlayerCharacter - iterator Pawn=BP_PlayerCharacter_C_1 Char=BP_PlayerCharacter_C_1 Char->PlayerState=KCharacterState_1
[2018.08.27-13.52.10:296][962]LogKSGMState: VeryVerbose: AKCharacterState::GetPlayerCharacter - Found Char=BP_PlayerCharacter_C_1 assigned to CachedCharacter

On Map6, the distance between start points is much bigger.

The problem reside in the fact the clients does not have all pawns. Only their pawn and not the other one.
The same code, to run through pawns have only one pawn.

In the client log :
[2018.08.27-13.48.29:324][220]LogKSGMState: VeryVerbose: AKCharacterState::GetPlayerCharacter - this=KCharacterState_1 CachedCharacter=None GetOwner()=None GetWorld()=T-Map6
[2018.08.27-13.48.29:324][220]LogKSGMState: VeryVerbose: AKCharacterState::GetPlayerCharacter - iterator Pawn=BP_PlayerCharacter_C_0 Char=BP_PlayerCharacter_C_0 Char->PlayerState=KCharacterState_0
[2018.08.27-13.48.29:324][220]LogKSGMState: VeryVerbose: AKCharacterState::GetPlayerCharacter - iterator Controller=KPlayerController_0 Pawn=BP_PlayerCharacter_C_0 Char=BP_PlayerCharacter_C_0

Is there any optimizations made on the server to not replicate players not visible.
This is the same code and the same map, except the distance between start point.

3 posts - 1 participant