Download

Problem with replicated array of custom struct

Hi,

I’m having a crash every time array is supposed to replicate to clients.
PIE with server + client.

And crash is at:


FRepLayout::CompareProperties_Array_r

// If nothing below us changed, we either shrunk, or we grew and our inner was an array that didn't have any elements
check( ArrayNum < CompareArrayNum || Cmds[CmdIndex + 1].Type == REPCMD_DynamicArray );

My code:


USTRUCT()
struct FWound
{
	GENERATED_USTRUCT_BODY()

public:

	float Damage;
	float Time;

	FWound()
		: Damage(1.0f)
		, Time(0.0f)
	{
	}
};


/** All the wounds this character currently has */
UPROPERTY(ReplicatedUsing = OnRep_Wounds)
TArray<FWound> Wounds;

/** Repnotify function for Wounds */
UFUNCTION()
virtual void OnRep_Wounds();


void UHealthComponent::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);
	
	DOREPLIFETIME(UHealthComponent, Wounds);
}

void UHealthComponent::OnRep_Wounds()
{
	
}

Any ideas why?
This is the first time I’m trying to replicate an array, am I missing something?

It turns out that every property in the struct must be UPROPERT(), otherwise it will crash.