Why do I get alternating LocalRole and RemoteRole strings per character?

I created a brand new UE C++ project with 3rd person template. The character has a tick function as follows:

#define ROLE_TO_STRING(Value) FindObject<UEnum>(ANY_PACKAGE, TEXT("ENetRole"), true)->GetNameStringByIndex((int32)Value)
void AMyProjectCharacter::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);
    const FString LocalRoleString = ROLE_TO_STRING(GetLocalRole());
    const FString RemoteRoleString = ROLE_TO_STRING(GetRemoteRole());
    const FString OwnerString = GetOwner() != nullptr ? GetOwner()->GetName() : TEXT("No Owner");
    const FString ConnectionString = GetNetConnection() != nullptr ? TEXT("Valid") : TEXT("In-valid");

    const FString Values = FString::Printf(
        TEXT("Local: %s\nRemote: %s\nOwner: %s\nConnection: %s"),
        *LocalRoleString,
        *RemoteRoleString,
        *OwnerString,
        *ConnectionString);

    FColor Color = GetNetConnection() != nullptr ? FColor::Green : FColor::Red;
    DrawDebugString(GetWorld(), GetActorLocation(), Values, nullptr, Color, 0.f, true);
}

When I play with 2 clients and Net Mode of Play As Client, I notice each character has two quickly alternating text as follows.

image

What causes this issue?

Note: There is no such a problem if I choose Play As Listen Server.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms