Hey,
I’m looping through the PlayerArray to create a widget for each player in the lobby. However, I don’t want to create a widget for the local player. This is what I have right now, it works fine, but surely there is a better way of doing this?
// This code works, but is there a better way of doing this?
for (APlayerState* Player : GetLobbyGameState()->PlayerArray)
{
APlayerController* LocalPlayerController = GetWorld()->GetFirstPlayerController();
if (LocalPlayerController)
{
if (LocalPlayerController->PlayerState && Player->GetUniqueId() == LocalPlayerController->PlayerState->GetUniqueId())
{
// Current player is the local player. Skipping widget creation.
continue;
}
}
// Creating widget for player...
}