Replicated Actors automatically Destroying and Respawning locally when Losing then Regaining Relevancy

Hi everyone,

I’m sure many developers may have run into bugs caused by replicated actors respawning themselves locally after losing and then regaining relevency (which is something replicated actors do).

Annoyingly, this causes the actor to call BeginPlay() again and this tends to be the cause of our bugs:
BeginPlay() is now no longer called only once for an actor, but an arbitrary number of times.

I haven’t found a good way to tell whether this is the first time BeginPlay() is being called for an actor, if we had access to a boolean that would allow us to seperate code that sets up the actor from code that we only want to execute once (such as code that interacts with other classes).
It wouldn’t be terribly unperformant to keep a local array of net IDs of actors that have lost relevancy, then to set a boolean before dispatching begin play if it is respawning after regaining relevancy. This would be a really cool feature for Unreal Engine.

Unless anyone knows a good way to do this already?

The only thing I can think of is using a replicated boolean to indicate that the client has already ran it, since that will still be true after respawning (but this will run into trouble with clients who joing a game in progress and also, it’s a waste of networking and server processing).

Oh, there’s also setting the actor to always relevant. But that’s not a good solution oftentimes.

Cheers.