Add multiples child componets at runtime in C++

Hey guys im strugling to create multiples child components outside constructor class

my code looks like that

UChildActorComponent *childComponent = NewObject<UChildActorComponent>(this);
FTransform transform = FTransform();
transform.SetLocation(FVector(0,0,0));
transform.SetRotation(FVector(0,0,0).Quaternion());
transform.SetScale3D(FVector(1,1,1));
this->AddComponent(FName(TEXT("child")), true, transform, childComponent);

And unreal always crash when I instantiante that actor.

1 Like