Multicast Client RPC actor parameter null after being spawned in the server

Hello, i want to spawn an actor from a certain class on the server and simulate physics. For this to happen on the clients i created a multicast client rpc with an actor as the parameter to enable simulated physics. The problem is, if i call this rpc after i just spawned the actor, the SpawnedActor parameter is null for the clients. The reason this happens is probably that the new actor isn’t know yet on the clients when the rpc comes, and because of that, there is no actor to make the 1:1 association. My current workaround for this is to do a timer with delay 0.1s, but isn’t there a better way to make this work, because i’m setting 0.1s, but in a real network environment that might not be enough and i can’t have a dynamic value for that.

Try to make a new variable (a bool for example) and set it to “RepNotify”. Perform the Physics On/Off thingy in the RepNotify function that you created with it and then it should work.

Because then the Server will spawn the Actor, set the bool to, for example, true (needs to be false before then)
and as soon as the client gets his version of the actor, it will replicate the variable and call the RepNotify function.

At least i think that should work.

I think eXi’s solution will work. There’s also another way - assuming that your actor that you spawn is a blueprint, you can add a variable and expose it on spawn to set whether the simulation is supposed to be on or off initially. Exposed on spawn variables are automatically replicated along with the spawned actor so you can safely use that variable to initialize any state you’d like the actor to be.

I’ve also ended up using that, but thanks anyway for the suggestion :slight_smile: