PlayerController owns Actor but cannot execute RPC

Hello,

I have a custom PlayerController that spawns Pawns on the server (and server properly replicates them to all of the clients) using RPC from PlayerController and I set Pawn’s owner as that PlayerController. The problem is that when I try to call RPC on Pawn I get a warning “LogNet: Warning: Rejected unwanted function”. As a test I check if Pawn’s owner is equal to PlayerController instance and it is but I cannot use RPC properly :D.

This is code from Player Controller that is spawning Pawns on the server:

UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable, BlueprintAuthorityOnly, Category = "Events")
void CreateUnit(TSubclassOf<AUnit> unitBase, FVector position);

void AProthegoriumPlayerController::CreateUnit_Implementation(TSubclassOf<AUnit> unitBase, FVector position)
{
	AProthegoriumPlayerState* state = (AProthegoriumPlayerState*)GetPlayerState();
	URace* raceInstance = state->RaceInstance;
	auto unitInstance = raceInstance->GetUnitInstance(unitBase);
	auto unit = (AUnit*)FProthegoriumHelpers::SpawnActor(unitBase, unitInstance, position, this);
	if (unit != nullptr)
	{
		unit->SpawnDefaultController();
	}
} 

AActor* FProthegoriumHelpers::SpawnActor(TSubclassOf<AActor> actorClass, AActor* actorTemplate, FVector position, AActor* owner)
{
	FActorSpawnParameters SpawnInfo;
	SpawnInfo.bNoCollisionFail = true;
	SpawnInfo.Owner = owner;
	SpawnInfo.Instigator = nullptr;
	SpawnInfo.bDeferConstruction = false;
	SpawnInfo.Template = actorTemplate;
	auto actor = owner->GetWorld()->SpawnActor<AActor>(actorClass, SpawnInfo);
	actor->SetActorLocation(position);
	return actor;
}

As you can see I set SpawnInfo.Owner = owner.

And here is the code for Pawn’s RPC:

UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable, Category = MainBase)
void TestFunction();

void AUnit::TestFunction_Implementation()
{

}

Do you have any ideas what could go wrong?

Thanks in advance, cloud

Before calling RPC on a Pawn I print to log if that Pawn has network owner (by HasNetOwner()) and it always return true, so I really don’t know what wrong is going on :smiley: