Problems swapping root component in code

I have class A which sets a root component in the constructor. But I have a need to use a different component as root compoenent in a child class constructor, but it doesn’t work.

	//ComponentA is original rootComponent
	RootComponent = newRootComponent;
	ComponentA.AttachT0(RootComponent);

I also have tried methods like detachFromParent, or just straight up change attachParent by hand but nothings works.

Please help

MyActor->SetRootComponent(MyComponent) ?

no it doesn’t work… I am trying to make a child component of the root component the new root component, and then make original root component the child component. I stepped in to SetRootComponent and didn’t get to the part when it switches root compoennt

SetRootComponent(NewRoot);
NewRoot->DetachFromParent();
OriginalComponent->AttachChildren.Remove(NewRoot);
OriginalComponent->AttachTo(NewRoot);

seems like unreal has a bug that’s what I did to fix it. DetachFromParent doesn’t remove the children reference from the parent so AttachTo method refused to attach since it would create a cycle