When i played Netmode as Client, and Number of Players = 1, everything gets weird.

trixylunamoon
Sun, 08 Sep 2024 14:47:56 +0000
Programming & Scripting

Just hard to understand Server-Client things in Unreal Engine,

When i set up the editor like this, “Play As Client and Number of Players = 1”

‘HasAuthority’ functions work well in Blueprint.

As you see.

But in the CPP, ‘HasAuthority’ always returns false.

void AMyCharacter::ServerDestroyThisCharacter_Implementation()
{
    if (HasAuthority())
    {
        if (IsValid(this))
        {
            Destroy();
        }
    }
}

If there’s a code like this, HasAuthority phrase never passed.

Actually, Destroy function checks the Authority Role and replicated internally,
so the Destroy function never completed either.

Is this normal ?

If so, we don’t need to test in the editor as client mode if we are making multiplayer games, do we?

Sombody help me to understand these thing fully T^T

3 posts - 3 participants