Replicating Static Mesh Actors Visibility

Hello, I am making a interactive archviz ˜game˜. My level is basically only a sun and a datasmith scene imported from revit. I`ve created a widget which can filter meshes by name( in my GI, I created a map that associates each mesh with a custom description coming from a .csv file.

So, the player can write in the widget something like “wall” to filter out all the walls in the level and hide them. It all works when playing alone. But when playing multiplayer, the clients cannot hide for all the other players. After research It seems like they cannot replicate because they do not own the mesh, but I could be wrong.

So, TLDR: I want to all the players have the ability to hide and unhide meshes via a widget.
Can someone please help?

if you do a Server RPC from something you do own like the PlayerController it should work

After some testing I am now suspecting that this isn’t a replication problem.

Let me explain further:

I’ve created a widget that is populated at runtime. The goal of the widget is to allow players to have multiple selections of “parameters” which comes from the .csv file.

If the player selects multiple “parameters”(buttons in a vertical box), the meshes that satisfies ALL conditions are filtered for isolation or to be hidden in the level.

The problem is that my level can have a lot of actors(100k+), and using a foreach loop every time the filter changes was very slow.

So, I had a idea to store all the relevant meshes on every possible selection at BeginPlay. It is indeed, much faster. But, to achieve this, I’ve created a function in my GameInstance that, after all sorting,grouping etc… It sets all variables and then creates a SaveGame object. All players that enters the game after that, will use the SaveGame to get the relevant data. Soo, if the server was the one which “updated” the database, the static mesh components are referenced by the “server side game”,
and if the client was the one updating, the references are based on their “client game”. So, any other player trying to use the filter will have invalid references pointed in their GameInstances.

Sorry for the long post and my english.

Thank you!

EDIT:
These are my RPC calls inside my Pawn

If the player trying to filter the meshes is the player which updated the database, the changes replicates to all other players, but if the player wasn’t the one that updated(and thus created the savegameobject), the changes won’t work for anyone

your passing through an object reference so that object also needs to be replicated or it will be Null, however i don’t recommend that as you said you have 100k actors.

what i’d do is assign a GUID or something cheap to the actors and use that to lookup the local copy

Hello, sorry for the slow response.
In regard your suggestions, I’ve changed all the relevant data and now instead of trying to replicate an array of components, I am sending a array of strings(like a GUID) to the clients, and then, all clients search locally for the corresponding component.
However, this still has some issues.
1- My project is actually a building with all the systems(structural,plumbing,electrical), with many actors. For instance, if I want to hide all plumbing actors, the array would be 30k+ actors.
Even using only strings, I can’t replicate because the array is too long and it is giving this error:

Error: Attempted to send bunch exceeding max allowed size. BunchSize=301079, MaximumSize=65536

So, that’s one problem, but I think I can get pass through this sending smaller parts of the array at a time.

My second problem is that, if I want to lookup all components using the strings of the array, it is very slow to find all.

A simple example is this:

In my GetSMComponentByID function i have this setup:

Trying to tackle this problem, i thought of creating this variable in every PlayerState, that, when BeginPlay, it maps all IDs to it’s relevant local reference of the component. But this is also, very consuming, so I’ve created a SaveGameObject to store this variable and be able to retrieve in later game sessions.

Man, multiplayer is such a PITA. Is there really no way to store a server reference of the components and the clients retrieve and get it´s “local” reference?

Feels like running in circles.

in that case you could just send a Tag, ie HidePlumbing and the local player can find/hide its own stuff.

or

  1. Can they be created in the level and then you dont need to replicate them at all
  2. RepNotify over MultiCast is likely a better idea here
  3. with big loops try breaking it up into multiple small loops with a delayuntilnextframe
  4. look in to Async Tasks.

oh and you could try EventDispatchers as well,

so the Mesh/Actor binds to a manager, the manager calls HidePlumbing and the mesh handles its own visibility