I have a Server->Client RPC function declared like this:
UFUNCTION(Client, Reliable, WithValidation, Category = "Inventory")
void ClientAddContainerToInventory(int32 containerIDinItemsDB);
void ClientAddContainerToInventory_Implementation(int32 containerIDinItemsDB);
bool ClientAddContainerToInventory_Validate(int32 containerIDinItemsDB);
that contains this code
void UInventory::ClientAddContainerToInventory_Implementation(int32 containerIndexInInventory)
{
if (!IsLocalClient())
return;
hud->AddContainerToInvWidget(containerIndexInInventory);
}
and for some reason it runs on the server instead of running on the client.
IsLocalClient() is defined like this:
bool UInventory::IsLocalClient()
{
if (!playerPawn) {
return false;
}
if (!playerPawn->GetController())
{
return false;
}
if (!playerPawn->GetController()->IsLocalController())
{
return false;
}
return true;
}
(All this code is in a class called Inventory that extends UActorComponent)
Thanks in advance!