Dynamic component creation

Interesting effect. Example code:



for (int i=0; i< this->amount; i++)
{
tmp = NewObject<UChildActorComponent>(this, UChildActorComponent::StaticClass());

tmp->SetChildActorClass(AMyActor::StaticClass());
tmp->CreateChildActor();

// register component
tmp->RegisterComponent();

// do attachment
tmp->AttachToComponent(this->GetRootComponent(), FAttachmentTransformRules::SnapToTargetIncludingScale);
childActors.Add(tmp);
}

All objects in childActors array has the same ID and location. If I change location via editor it changed for everyone. Looks like NewObject returns me link to the same ActorComponent every time.