Call RPC on replicated actors only after begin play is finished

Hi,
I’m wondering if any network gurus out there might know of a reliable way to have an RPC call from server to the client buffer itself and wait until after begin play is finished on the client actor.

Currently I have a situation where I’m spawning a replicated actor on the server and then calling an RPC on it soon after which is trying to run on the client replicated version before it has finished it’s BeginPlay event and is breaking.

Are there any clever solutions to this?

Begin play event is finished with your last node in that event and/or when game ends. Seems that you need to change server/client logic when you spawn that actor.
Can you give an example to get a more concrete answer?

An example would be say I have a replicated actor called Person. In Person the BeginPlay event has some set up it needs to do with getting and casting owner lets say. I have a set of logic that wants to create a person and have them dance immediately.

On the server I call spawn Person.
Person starts replicating.
On the server, using the person I have just spawned I call a multicast RPC: Person.Dance
On the client, it tries to call Person.Dance on it’s own Person but it hasn’t finished it’s BeginPlay
Things go wrong and it breaks

How could I ensure that Person on the client is ready for Person.Dance to be called?
Or alternatively how could I get the client to hold that call until it’s ready?

  • Create event on actor “Person” that runs on Owning client. In that function/event put all logic for client side setup.
  • Spawn “Person” on the server, call Event that executes on owning client, call Dance (multicast or use RepNotify). Probably it’s better to use RepNotify and on client use Switch Has Authority -> connect Remote Node -> play dance animation or whatever you want.

If you ever want to use GetOwner() on the client this method doesn’t seem very reliable though. I tried this and found that I got None from my GetOwner calls. BeginPlay seems to have the owner set reliably.

Create a new event and call it for example InitClient, in graph panel set Replicates: Run on Owning Client
12.jpg