Replays: Actors not visible / not valid when replay is recorded from client

I use slightly modified lyra “equipment actors” spawned by “equipment instance” logic (the thing I addes is that instance can be visible right now or not and it changes spawned actors visibility and linked animation layer. Eg you can have two handed ranged weapon equiped along with a sword, but only 1 item is visible at 1 time).

void UECREquipmentInstance::SpawnEquipmentActors(const TArray<FECREquipmentActorToSpawn>& ActorsToSpawn)
{
	if (APawn* OwningPawn = GetPawn())
	{
		USceneComponent* AttachTarget = OwningPawn->GetRootComponent();
		if (ACharacter* Char = Cast<ACharacter>(OwningPawn))
		{
			AttachTarget = Char->GetMesh();
		}

		const UECRPawnComponent_CharacterParts* CosmeticComponent = OwningPawn->FindComponentByClass<
			UECRPawnComponent_CharacterParts>();
		FGameplayTagContainer CosmeticTags = {};
		if (CosmeticComponent)
		{
			CosmeticTags = CosmeticComponent->GetCombinedTags(FECRGameplayTags::Get().Cosmetic_ActorSubclass);
		}

		for (const FECREquipmentActorToSpawn& SpawnInfo : ActorsToSpawn)
		{
			TSubclassOf<AActor> ActorClass = SpawnInfo.ActorSelectionSet.SelectBestActor(CosmeticTags);
			AActor* NewActor = GetWorld()->SpawnActorDeferred<AActor>(ActorClass, FTransform::Identity,
			                                                          OwningPawn);
			NewActor->FinishSpawning(FTransform::Identity, /*bIsDefaultTransform=*/ true);
			NewActor->SetActorRelativeTransform(SpawnInfo.AttachTransform);
			NewActor->AttachToComponent(AttachTarget, FAttachmentTransformRules::KeepRelativeTransform,
			                            SpawnInfo.AttachSocket);
			NewActor->SetActorHiddenInGame(!bVisible);
			if (!NewActor->GetIsReplicated())
			{
				NewActor->SetReplicates(true);
			}

			SpawnedActors.Add(NewActor);
		}
	}
}

However, the problem is that weapons are visible when replay is recorded by listen server, but not visible when replay is recorded by client. Though, some actors like grenades are visible.

The problem was that actors I didn’t see were not replicated. Grenaded were replicated, since they need a movement sync, so they were acknowledged by the replay system and it remembered them.

Setting replication on runtime (NewActor->SetReplicates(true);) didn’t work, the actor needs to be replicated by default (bReplicates in CDO). Either a checkbox in blueprint, or

AECREquipmentActor::AECREquipmentActor(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{
	bReplicates = true;
}