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?
asked Jul 12 '18 at 10:28 AM in C++ Programming
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
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.
answered Jul 12 '18 at 04:05 PMBrian Johnstone (suspended)
Follow this question
Once you sign in you will be able to subscribe for any updates here