[Free] Multiplayer Network Compendium | Gets you started with Multiplayer in UE!

Hey there,

I should have been more clear about that.
The Variable is NOT replicated, but since the PlayerState is replicated, it can fill ITSELF into the the Array on all Clients. Probably doing this in “PostInitializeComponents”. So the client version of a PlayerState adds itself to the Clients PlayerArray.

I will alter/add this information.

Cheers!

EDIT:

Until I find time to add this information, is the Part INSIDE of the PlayerState, that manages adding itself to the PlayerArray:



void APlayerState::PostInitializeComponents()
{
	Super::PostInitializeComponents();

	UWorld* World = GetWorld();
	// register this PlayerState with the game's ReplicationInfo
	if ( World->GameState != NULL )
	{
		World->GameState->AddPlayerState(this);
	}

        .....
}


PostInitializeComponents is called on all instances of the PlayerState. So on the Server and on the Client Versions. So every instance adds itself to the GameState’s PlayerArray.
You could also do this only on the Server and replicated the Array, but why wasting bandwidth? (:

The GameState itself also gathers all PlayerState, for the case there were already some PlayerStates and the GameState wasn’t ready yet:



void AGameState::PostInitializeComponents()
{
	Super::PostInitializeComponents();

       ...

	for (TActorIterator<APlayerState> It(World); It; ++It)
	{
		AddPlayerState(*It);
	}
}


Of course, this is being a “Unique” Add, so no duplicated entries. The “AddPlayerState” function has the following implementation:



void AGameState::AddPlayerState(APlayerState* PlayerState)
{
	// Determine whether it should go in the active or inactive list
	if (!PlayerState->bIsInactive)
	{
		// make sure no duplicates
		PlayerArray.AddUnique(PlayerState);
	}
}


I hope that sorts it for now (: