Client RPC function executed on server

I have a function that needs to be called by the server and executed by the client. It is declared like this:

UFUNCTION(Client, Reliable)
	void ClientInitWeapons();

It is called on the server. When checking directly in the function itself using HasAuthority, it turns out that the function, although it has the “Client” modifier and is called on the server, is executed ONLY on the server:

void ANoNameCharacter::ClientInitWeapons_Implementation()
{
	if (!HasAuthority()) {
		UE_LOG(LogTemp, Warning, TEXT("ClientInitWeapons client"));
	}
	else {
		UE_LOG(LogTemp, Error, TEXT("ClientInitWeapons server"));
	}
}

331689-screenshot-2021-03-07-164335.png

3 Likes

Have you tried to run the game as an administrator?

Hi @byalexeykh, I am facing the same problem. Did you find a solution?

From the Requirements and Caveats section of this document: 3. If the RPC is being called from server to be executed on a client, only the client who actually owns that Actor will execute the function.

So, in this case I guess your character is owned by server but you want it to be owned by client. Try possessing the character from the client to get its ownership.

3 Likes

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