Download

Serialize and save actor

Hi,
I have an array of actors that I want to save to disk at runtime. The actor has some common properties (FString and float) plus a child actor who has a certain number of nested static meshes with tags.
I’ve tried something like this:

USaveGame* savedGame = UGameplayStatics::LoadGameFromSlot("TEST3", 0);
UL_SaveConfiguration* savedConfiguration = Cast<UL_SaveConfiguration>(savedGame);
for (auto& furniture : savedConfiguration->furniture)
{
	FActorSpawnParameters SpawnInfo;
	FRotator Rotation(0.0f, 0.0f, 0.0f);
	FVector Location(0.0, 0.0f, 0.0f);
	Location.Z = 0;
	AL_GenericFurniture* actor = GetWorld()->SpawnActor<AL_GenericFurniture>(FVector(0.0f, 0.0f, 0.0f), FRotator(0.0f, 0.0f, 0.0f), SpawnInfo);
       UClass* furnitureChildActorClass = furniture->FurnitureChildActor->GetClass();

		UChildActorComponent actorChildActor = actor->FindComponentByClass<UChildActorComponent>();
		actorChildActor->SetChildActorClass(furnitureChildActorClass);
	
	}

So that I can get the class of child actor, but all I get is an access violation error.
How can I save the actors together with child actors , static meshes and meta tags?
Thanks.