Have you checked the logs? Seems like you’re sending too much data, so the logs will give you a warning that looks like this: "FBitWriter overflowed! ..."
FastArrays are amazing, and they prove helpful when your array becomes big.
Yes, there is an example and that is somehow similar to what you did. You can check ActorChannel.h:
// --------------------------------
// Subobject Replication state
//
// Concepts:
// ObjID - this is an arbitrary identifier given to us by the game code.
// RepKey - this is an idenifier for the current replicated state.
//
// ObjID should be constant per object or "category". Its up to the game code. For example the game code could use 0 to determine if an entire array is dirty,
// then usen 1-N for each subobject in that list. Or it could have 5 arrays using 0-4, and then use 100*ArrayNum + idx for the items in the array.
//
// RepKey should change as the subobject changes. Each time a subobject is marked dirty, its RepKey should change.
//
// GameCode should call ::KeyNeedsToReplicate(ObjID, RepKey) to determine if it needs to replicate. For example:
//
//
/*
bool AMyActorClass::ReplicateSubobjects(UActorChannel *Channel, FOutBunch *Bunch, FReplicationFlags *RepFlags)
{
bool WroteSomething = false;
if (Channel->KeyNeedsToReplicate(0, ReplicatedArrayKey) ) // Does the array need to replicate?
{
for (int32 idx = 0; idx < ReplicatedSubobjects.Num(); ++idx )
{
UMyActorSubobjClass *Obj = ReplicatedSubObjects[idx];
if (Channel->KeyNeedsToReplicate(1 + idx, Obj->RepKey))
{
WroteSomething |= Channel->ReplicateSubobject<UMyActorSubobjClass>(Obj, *Bunch, *RepFlags);
}
}
}
return WroteSomething;
}
void UMyActorSubobjClass::MarkDirtyForReplication()
{
this->RepKey++;
MyOwningActor->ReplicatedArrayKey++;
}