Does the replication of a property can be set at runtime

In our workflow, at runtime init, we want to force some FProperty to be replicated (let’s say it’s to avoid human error when defining actor properties by code or BP). Could you confirm that we can do this :

MyProperty->PropertyFlags |= CPF_Net;

Looking at the internets and AIs the answers vary.

Hi,

For a property to be replicated, it should have the “Replicated” UPROPERTY metadata specifier, and it should be registered in the actor’s GetLifetimeReplicatedProps function. I don’t believe that just changing the property’s flags at runtime will be enough to make it replicate.

If you want to change at runtime whether a property is replicated, you can use the COND_Custom replication condition: https://dev.epicgames.com/documentation/en\-us/unreal\-engine/replicate\-actor\-properties\-in\-unreal\-engine\#custompropertyreplication

Thanks,

Alex