Hello,
I have an actor I created in the editor and it loads on clients and on the server. I need to call server RPCs on this actor from the clients so obviously it needs a connection to the player.
In the client:
void ALmdaTileGrid::BeginPlay()
{
Super::BeginPlay();
if (!HasAuthority()) {
ALmdaPlayerController* pc = Cast<ALmdaPlayerController>(GetWorld()->GetFirstPlayerController());
ensure(pc);
if (pc) {
SetOwner(pc);
pc->ServerTakeOwnershipOfGrid(this);
}
}
}
So I’m getting the local player controller on the clients, which definitely exists and is replicated by now.
On the server:
void ALmdaPlayerController::ServerTakeOwnershipOfGrid_Implementation(ALmdaTileGrid* grid)
{
grid->SetOwner(this);
TRACE("Reparented tile grid [%s] to [%s]", *grid->GetName(), *grid->GetOwner()->GetPathName());
}
This correctly shows the owners for the clients as being their player controllers.
The problem is this, on the client:
void ALmdaTileGrid::OnRep_Owner()
{
Super::OnRep_Owner();
if (GetOwner()) {
// Always null on ONE client. The other client works fine.
}
}
I’m completely stuck so absolutely any help will be priceless.
Thanks