I used the subobject replication on Character child class.
The replication code in subobject:
void UIndicatorsComponent::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(UIndicatorsComponent, Health);
}
But this code runs only once. Consequently Health property is not replicated when it changes.
Code in class that replicates this subobject:
bool ASADCharacter::ReplicateSubobjects(class UActorChannel *Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags)
{
bool WroteSomething = Super::ReplicateSubobjects(Channel, Bunch, RepFlags);
if (Indicators != nullptr)
{
WroteSomething |= Channel->ReplicateSubobject(Indicators, *Bunch, *RepFlags);
}
return WroteSomething;
}
Subobject has this :
UPROPERTY(Replicated)
float Health;
virtual bool IsSupportedForNetworking() const override
{
return true;
}