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

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

1

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

‘HasAuthority’ functions work well in Blueprint.

2

3

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

I encountered some oddities when testing multiplayer in PIE. In 90% it works fine, but sometimes RPCs did not work correctly. When running Standalone Game - everything worked as intended, but it took much longer to load. So you should check it out.

image

Also, in most cases it is better to use the IsServer check instead of HasAutority, since the latter is not always obvious, and it is easier to make a mistake with it.

1 Like

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