Initial replication complete event?

Is there a event that is fired when the initial replication of properties and components of an actor is complete?

UE3/UDK had a event called PostInitialReplication or something. Is there a similar counterpart in UE4?

As far as I can tell there does not appear to be a signal sent to indicate that everything is initialized. What specific things do you want to wait on before running code? Is it a specific variable state, or do certain components or network objects need to be instantiated first?

What I found was recommendations that you either do this in Tick or on a looping timer and check the specific objects or variables that need replication before running your code, and once those conditions are met (like using ReplicatedUsing and the linked function setting some extra boolean that the variable has been replicated at least once) running your startup code and then canceling the timer. But, it’s hard to give specific advice unless you have a more specific situation you want to handle.

I did a small test and here are the findings

BeginPlay is called only after all properties that is inherent to the actor has completed replication. It’s safe to use all replicated values in begin play except any pointer to other actors as they may replicate in before or after your actor.

So in BeginPlay its safe to use primitive variables like int,float etc and any subobjects or components that are owned by your actor. Just don’t assume other replicated actors to be present whole yours is calling it’s begin play

The repnotify functions would be called before begin play but all owned replicated values are valid and safe just like in begin play . If there are more than one repnotifies then their order of callback is not guaranteed but all the values of all repliacted variables are guaranteed to be valid before first repnitify is called.

Ex. Checking replicated float on repnotify or begin play is safe
Checking owning controller or a pointer to other replicated actor in begin play is not safe

The engine does something like this

  1. Send all replicated values
  2. Receive all replicated values
  3. Call repnotify for each repnotify variable
  4. Call begin play
2 Likes

AActor has the following overrideable method :

/** Always called immediately after spawning and reading in replicated properties */
virtual void PostNetInit();
2 Likes