Hey there.
So I have the problem, that I have a big amount of data, potentially a few hundred MBs (Mesh Data), that are loaded/generated at runtime and need to be replicated to every Player.
In the past, I was using RPCs to split the Data into Chunks and send them one by one, but this solution was very hacky and I was dissatisfied with it. So now I opted to use FastArrayReplication.
Here are some code exepts:
USTRUCT()
struct FFastVector : public FFastArraySerializerItem {
GENERATED_BODY()
FFastVector() = default;
FFastVector(const FVector Vector) : Vector(Vector) {};
UPROPERTY()
FVector Vector;
};
USTRUCT()
struct FFastArrayVector: public FFastArraySerializer {
GENERATED_BODY()
UPROPERTY()
TArray<FFastVector> Items;
bool NetDeltaSerialize(FNetDeltaSerializeInfo & DeltaParams) {
return FastArrayDeltaSerialize<FFastVector, FFastArrayVector>(Items, DeltaParams, *this);
}
}
template<>
struct TStructOpsTypeTraits<FFastArrayVector> : TStructOpsTypeTraitsBase2<FFastArrayVector> {
enum {
WithNetDeltaSerializer = true,
};
};
------------------------------------------------------
class AMyActor : public AActor {
GENERATED_BODY()
UPROPERTY(Replicated)
FFastArrayVector ReplicatedVectors;
public:
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override {
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AMyActor, ReplicatedVectors)
}
...
}
The Vertices are filled similar to this:
void AMyActor::FillReplicatingData(const TArray<FVector>& Vertices) {
for (const auto& Vertex : Vertices) {
const int32 Position = ReplicatedVectors.Items.Add(Vertex);
ReplicatedVectors.MarkItemDirty(ReplicatedVectors.Items[Position]);
}
I original understood that this Method of Replication does not have a size limitation and can be used to send large amounts of data, yet, if you take a look at the log you see this and there is no actual data received on the client:
LogNetFastTArray: Warning: NumChanged > GetMaxNumberOfAllowedChangesPerUpdate: 41180 > 2048. (Write)
LogNetFastTArray: Warning: NumChanged > GetMaxNumberOfAllowedChangesPerUpdate: 196599 > 2048. (Write)
LogNetFastTArray: Warning: NumChanged > GetMaxNumberOfAllowedChangesPerUpdate: 41180 > 2048. (Write)
LogNetFastTArray: Warning: NumChanged > GetMaxNumberOfAllowedChangesPerUpdate: 41180 > 2048. (Write)
LogNetPartialBunch: Error: Attempted to send bunch exceeding max allowed size. BunchSize=4065126, MaximumSize=65536
So am I missing something? Or is this method also limited to 64K-Bytes? And if so, is there any way to send this much data to another user (including using Plugins/Libraries, Marketplace or not)
Thanks in advance!