Hi. I have a actor class and in the onconstruction function i create many child actors(in childactorcomponents). i use onconstruction to have them visualized and editable through my own editor mode. for persistance i use an array which keeps track of the child actors. on construction reads the array and creates the childs.
Sadly these child actors forget all their values that the construction script set as soon as i play the game(PIE). A partial workaround is to tag the variables UPROPERTY in the child actors class. but that does not work all of the time(they have a variable called “name” for example, which is just not remebered).
i am kind of frustrated now. is there another approach i could take to have child actors that appear in editor?
greetings
edit: some code
//At some place(BeginPlay of my level actor):
for (const FActorGridInfo& ActorGridInfo : ActorGrid)
{
UChildActorComponent* ChildActorComponent = NewObject<UChildActorComponent>(this);
ChildActorComponent->SetupAttachment(RootComponent);
ChildActorComponent->SetChildActorClass(ActorGridInfo.ActorClass);
ChildActorComponent->CreateChildActor();
AGridActor* GridActor = Cast<AGridActor>(ChildActorComponent->GetChildActor());
if (GridActor)
{
GridActor->Position = ActorGridInfo.Position;
GridActor->Orientation = ActorGridInfo.Orientation;
GridActor->Name = ActorGridInfo.Name;
GridActor->ParentGridLevel = this;
UE_LOG(LogTemp, Warning, TEXT("The Actor's name is %s"), *GridActor->Name.ToString());
}
}
//Later in another place:
void AGridDoorActor::BeginPlay() //Is a subclas of AGridActor
{
Super::BeginPlay();
UE_LOG(LogTemp, Warning, TEXT("My name is %s"), *Name.ToString());
}
The first output is correct, but the second is always “My name is None”