The code in my parent-actor-constructor:
UWorld* world = GetWorld();
if (world != nullptr)
{
FActorSpawnParameters spawnParams;
spawnParams.Owner = this;
spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
AC_BoardSpot* newBS = GetWorld()->SpawnActor<AC_BoardSpot>(AC_BoardSpot::StaticClass(), GetTransform(), spawnParams);
newBS->AttachToActor(this, FAttachmentTransformRules::KeepRelativeTransform); // <<< problem here
}
Error in SceneComponent.cpp when I drag the parent into the level:
if (ensureMsgf(AttachParent == nullptr || !AttachParent->AttachChildren.Contains(this), TEXT("SetupAttachment cannot be used once a component has already had AttachTo used to connect it to a parent."))) // UE4Editor-Win64-DebugGame.exe has triggered a breakpoint.
Both actors use a dummy root if that matters:
// Dummy Root.
RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT(ROOT_NAME));
RootComponent->SetMobility(EComponentMobility::Static);