unreal-engine4unreal-blueprintunreal-engine5

Unreal Engine, How to replicate an Actor to ONLY certain clients


I want to be able to spawn a replicating actor (any actor) on a server and have it only replicate to certain clients. For example, lets say we have a team of people working on a project. I want to share part of my design (could be any UE actor) with some of my other teammates that are also connected to the server and let them tweak it with me in real time. Then, once we are satisfied, we replicate it to all clients connected. How would this be achieved?

I have the following code, I can spawn a replicating actor on the server: Spawn actor on server

Next, I could do the same, but multicast it to everything: Spawn actor on clients as well as server

But this would ruin the idea of replication, since it's "controlled by the server" so that anything that happens on the server propagates to each of the clients who it's replicated to. Therefore, we would have to create our own backend for replication.

I know there is a thing called "replication condition" that you can add to a replicating properties. However, I am unsure how to achieve this with c++, let alone blueprints. I can do both, but blueprints is preferred.

Thank you in advance, I'm having a lot of trouble understanding this.


Solution

  • i'm not entirely sure. but you can spawn the actor on the server, set the appropriate owner. and on the actor you can override a function that determines if it's relevant for a specific client. see https://dev.epicgames.com/documentation/en-us/unreal-engine/API/Runtime/Engine/GameFramework/AActor/IsNetRelevantFor

    https://dev.epicgames.com/documentation/en-us/unreal-engine/actor-relevancy-in-unreal-engine

    https://cedric-neukirchen.net/docs/multiplayer-compendium/actor-relevancy-and-priority/