RepNotify not triggering when modifying a subobject in an array

I have an actor component. The actor component has a TArray of UMyObject* (UMyObject derives from UObject). The array is declared like this:

UPROPERTY(ReplicatedUsing = OnRep_MyArrayUpdate, EditAnywhere, BlueprintReadWrite))
TArray<UMyObject*> MyArray;

I followed this, and my actor component, its array, and each UObject in the array all replicate just fine. (I use Add/RemoveReplicatedSubObject())

The problem is that OnRep_MyArrayUpdate, my RepNotify function for the array, is only triggered when I add or remove objects. I want to know if it’s possible to get it to trigger when I modify a property inside of a UMyObject in MyArray.

For instance, if UMyObject has a variable declared like this:

UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite)
int32 Value1;

And I do this:
MyArray[1]->Value1 = 10;
I want OnRep_MyArrayUpdate to trigger.

IMPORTANT: I am editing these values on the server. The values successfully replicate to clients. It’s just the RepNotify that’s not happening.

I tried adding REPNOTIFY_Always like this:

void UMyActorComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);

	DOREPLIFETIME_CONDITION_NOTIFY(UMyActorComponent, MyArray, COND_None, REPNOTIFY_Always);
}

, which this post and this post both say to do, but RepNotify is still not being triggered. I’m not sure what else to do or if what I want is even possible.

Thanks in advance for any help! :slightly_smiling_face:

4 Likes