Download

Are all Player Controllers on the server supposed to be owned by the server?

Are all Player Controllers on the server supposed to be owned by the server? I was under the impression from what I read that Player Controllers are owned by the connecting client.

I’m seeing them all all owned by the server on the server.

I cycle through the Player Controllers on the server and get debug logs by


if (realObjectToSync->GetWorld()->IsServer())
    {
        if (UGameplayStatics::GetPlayerController(GetWorld(), i)->Role == ROLE_Authority)
        {
            UE_LOG(LogTemp, Warning, TEXT("SERVER: Role authority"));
        }
        else
        {
            UE_LOG(LogTemp, Warning, TEXT("SERVER: Role not authority"));
        }
        if (UGameplayStatics::GetPlayerController(GetWorld(), i)->HasAuthority())
        {
            UE_LOG(LogTemp, Warning, TEXT("SERVER: Has authority"));
        }
        else
        {
            UE_LOG(LogTemp, Warning, TEXT("SERVER: Not has authority"));
        }
    }

And with two total connected players(one listen-server, one client) all Player Controllers are HasAuthority() and ROLE_Authority on the server.

Has Authority and Ownership is not the same thing. The server does have authority of the Player Controller while a specific client owns the Player Controller. Authority is given to the one who spawns the replicated Actor (only the server can replicate actors) and ownership is assigned when a Player Controller is created and dynamically through possession of a pawn and its owned children.