How do I spawn actors only to specific clients

I want to be able to spawn actors on specific clients, say all odd clients that join the server. I understand that I could spawn a replicating actor using an RPC from a client to spawn it on the server then replicate to all clients. I want something similar, however, when it replicates, to only replicate to specified clients.

For example, I want to spawn a message (3d text) and choose who to send the text to, then I want to be able to spawn that actor on the server and replicate it to who I want to. I don’t want it to replicate to everyone and I don’t want it to only replicate to the owner.

What would be the best way to approach this?

Would I set a custom replication condition? if so, how do you change the replication condition in blueprints? I can do c++, but would prefer blueprints.

2 Likes

Also interested in this! I am working on a ping system seen in most first person shooters, and trying to limit pings to spawn only for allies of the pinging player.

1 Like

Hello hello, I was going through r/UnrealEngine and found a solution for it. The answer is to use either a replication graph (super convoluted), or do override the method “IsNetRelevantFor” in the actor you are creating. Note that this has to be in c++, you can’t override it in blueprints.

IsNetRelevantFor just tells the replication manager whether or not to “replicate” the object to a given client. So, you can keep track of the list of “pinging” players and check in IsNetRelevantFor if that specific player is in your list of pinging players. IsNetRelevantFor is called on each client before replication :).

1 Like