Add/Spawn Child Actor from code?

Hello, I’m having a really hard time replicating the Add Child Actor Component logic in cpp.

This is my current logic:

static FActorSpawnParameters spawn_parameters;
spawn_parameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;

FTransform xform = GetFlockingLocation(m_Units.Num() + 1);

// Spawn
auto* new_unit = static_cast<AUnit*>(GetWorld()->SpawnActor(m_UnitClass, &xform, spawn_parameters));
if (!new_unit)
{
	UE_LOG(LogTemp, Warning, TEXT("Failed to create an Unit!"));
	return false;
}

// Attach
new_unit->GetRootComponent()->AttachToComponent(GetParentComponent(), FAttachmentTransformRules::KeepRelativeTransform);

m_Units.Push(new_unit);

It executes correctly, but the actors are not visible neither in the viewport nor in the world outliner. I’m 99% sure the problem lies with the “Attach” section. Could someone point me in the right direction? Thanks.