Runtime spawned cablecomps not spawned on late connected client

Hi,

I have an issue with networked spawning of cable components.

The goal: Spawn Constraint on server, then spawn cable components on all clients.

Issue: The spawning works as intended for all clients connected at the time the event runs, but any clients joining in after the event happened do not know about the spawned cable components.

So the question is, how do I handle events that happened before the client connects to the host, so that new clients logging in also have cable components spawned?

I will attach screen captures if there are any questions

That’s exactly the reason you shouldn’t use a replicated event for this.

Replicate a variable instead. You can use RepNotify to also get notified (on the client) when the variable has been received. This includes client who may join 5 hours later (if the object is still relevant). In blueprints when you enable RepNotify the function “OnRep_VariableName” is automatically created.

Thank you for the quick response.
Can you shed some light on how I can use rep’ed variables to do spawning and destroying of components.
It’s a dynamic system where you can spawn cables and constraint to multiple objects, from any actor that has the actor component where the cables are handled. Flicking it between active & deactivated won’t do the job in my case.

Hmm so from what I gather, you have an actor which acts as a source for a various number of cables, that can be attached to various entities ?

Can you describe exactly what a constraint is ? Is is a component, actor, object, struct ? If it has replication capabilities it sounds like a good place to handle it.

The constraint is a physics constraint component (only spawned on server)

The setup looks like this;

An actor (let’s say a human character), which at some point during runtime has the AC (Actor Component) “Rigging” added to it, Calls the function Call2Action SpawnCable on the rigging component with information on:

  • What the Source actor of the cable is (for instance a hand)
  • What the Target actor is (for instance a box)
  • Which socket on the target actor it will attach to
  • Optional intial length of the cable

The Component then runs some validity checks and runs a new event for spawning a constraint and cable:

Spawning of Cables on client:


Spawning of Constraint on server:


I also hold information about the cables in structs which are mapped to names (sockets on mesh), and as far as I know maps can’t be replicated, so replicating the state of the cables might prove difficult. It works with the exception that the cables’ state are unknown to new clients joining, and I can’t read the value from the constraints’ maps since they are not replicated (The maps I can’t read from are only used for the constraint so technically only the server needs to know of them)

Edit: On second thought I could maybe create structs that hold structs in order to get RepNotify. Any known pitfalls here?

So from the looks of it, you could enable Replication on the Constraint component, and enable replication of its properties Cable Length, Attach Socket Name, SMLoad, and Source Actor.

Then in Constraint BeginPlay, branch for client side (not dedicated server) and spawn the cable there using those variables which should be available.

This way the constraint component is essentially acting as a data holder and persistent multicast event, for each added cable.

That sounds like a good idea, I’ll see if I can make it work. I won’t have time until a few days time, but sounds like it’ll work, so I’ll mark it as solved :slight_smile: Thank you