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:

REPNOTIFY_Always on the array cannot help here, it only re-fires the array notify when the array property itself changes, it has no idea what happens inside the elements.

the notify belongs on the object. give UMyObject its own rep notify, UPROPERTY(ReplicatedUsing = OnRep_Value1), and the client fires that when Value1 changes on that specific object. if the component has to react to it, call an event on the component from inside the object notify rather than expecting the array notify to see it.

in blueprint the same idea is a replicated variable with your own on rep function on the object, the part that needs c++ in stock ue its making the plain object replicate at all. blueprint object replication from fab is a UObject replication plugin that puts replicated variables and rep notifies on blueprint objects, ue5.0 to 5.8.

btw i used blueprint object replication from fab https://www.fab.com/listings/e26dcf07-7c78-4e67-8e56-272cf6df8021 it worked for me