Hey, iam curently trying to bring my Blueprint “Code” over to C++. Iam struggeling about a … clearly simple problem.
Iam trying to add a BoxComponent to an Actor at runtime wich is not the addin Actor.
Cant get this thing to work… I have tried many variations of attaching the box to the new parent but none worked… maybe there is also a problem with my code…
void ABrush_Master::CreateTraceBox(AActor* Parent, FVector Location, FVector Extents, FRotator Rotation, ECollisionChannel TraceChannel, bool Visivle, bool ArrowComponent)
{
//No Valid Parent just exit
if (!Parent) return;
FTransform _Transform = FTransform(Rotation, Location, FVector(1, 1, 1));
UBoxComponent* _BoxComponent = NewObject<UBoxComponent>(Parent);
_BoxComponent->SetWorldTransform(_Transform);
_BoxComponent->SetBoxExtent(Extents);
_BoxComponent->SetVisibility(true);
_BoxComponent->SetHiddenInGame(false);
_BoxComponent->AttachParent = Parent->GetRootComponent();
//Parent->AddOwnedComponent(_BoxComponent);
//_BoxComponent->AttachTo(Parent->GetRootComponent());
}