Hello, I’ve got an actor that is placed in the level with a couple replicated functions defined:
UFUNCTION(Reliable, Server, WithValidation)
void ServerAddModifications(const FData& MyData);
virtual void ServerAddModifications_Implementation(const FData& MyData);
virtual bool ServerAddModifications_Validate(const FData& MyData) { return true; }
UFUNCTION(Reliable, NetMulticast, WithValidation)
void ClientAddModifications(const FData& MyData);
virtual void ClientAddModifications_Implementation(const FData& MyData);
virtual bool ClientAddModifications_Validate(const FData& MyData) { return true; }
Nothing I can seem to do enables the clients’ invocations of ServerAddModifications to reach the server. ClientAddModifications always properly broadcasts the call to all the clients.
Since this is an actor spawned in the world, I’ve heard tell of having to set the owner, and/or override GetNetConnection. GetNetConnection is the closest I’ve come to get this working, but I hit another snag:
// What to put here???
if (GetWorld()->NetDriver->ClientConnections.Num())
return GetWorld()->NetDriver->ClientConnections[0];
else
return GetWorld()->NetDriver->ServerConnection;
As written, the server will receive invocations of the RPC from the first client. If switched to the second client’s connection, it will also work thusly. The same behavior applies if I try to grab any of the two replicated Player Controllers and use their connections.
Attempts at using SetOwner here have failed, I believe because Unreal keeps trying to replicate the value of Owner? Not sure if so, or where to place the call to SetOwner, or which player controller to use as the owner on the server (same issue).
Incidentally, nothing about the above changes if the actor is spawned. Only actors which have multiple instances on the server (such as PlayerControllers) work properly if there is more than one client, because there is more than one net connection for each client? I’m missing something here, any help would be appreciated!