So I have some actor spawned from the PlayerController, let’s call that actor “CheatActor”, and I would like to fire client RPCs to server, and it’s not working.
From the RPC Doc, it says that
- The Actor must be replicated
2.If the RPC is being called from client to be executed on the server, the client must own the Actor that the RPC is being called on.
I wrote the following code, they should satisfy those requirements:
ACheatActor::ACheatActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
bReplicates = true;
bAlwaysRelevant = true;
}
And, the Cheat Actor is spawned in the PlayerController, which sets the Cheat Actor’s owner to the PlayerController
void APlayerController::BeginPlay()
{
Super::BeginPlay();
CheatActor = GetWorld()->SpawnActor<AElekCheatActor>(AElekCheatActor::StaticClass(), FTransform());
CheatActor->SetOwner(this);
}
Are these enough to setup RPC from a PlayerController spawned actor for client to server RPC? Why is the RPC still not working?