I have an ParentActor with a TArray of Actors
UPROPERTY(EditAnywhere)
TArray<AExampleActor*> ActorList;
I call OnConstruction and everything almost works fine except…
void OnConstruction(const FTransform& Transform)
{
if (GetWorld() && ActorList.Num() == 0)
{
for (int Actor= 0; Actor< NumActors; ++Actor)
{
FTransform Translation = CalculateTranslation(Actor);
FTransform SpawnTransform = Transform + Translation;
AExampleActor* Tile = GetWorld()->SpawnActor<AExampleActor>(SpawnTransform.GetTranslation(), SpawnTransform.GetRotation().Rotator());
AExampleActor->AttachToActor(this, FAttachmentTransformRules(EAttachmentRule::KeepWorld, false));
ActorList.Add(Tile);
}
}
}
I get one group of actors which are connected to the ParentActor as expected but I also get a second group of actors spawning which seem to have forgotten they have any attachment to the Parent . From the debugger it looks like this group is created when I initially click on the ParentActor in the editor but before I have dragged it into the world yet. Is this the expected behaviour?
Thanks