UChildActorComponent warning on Register despite having set Parent's root component

Hi,

I’m encountering the following error when registering a UChildActor component to my actor:

LogActor: Warning: [Actor name] has natively added scene component(s), but none of them were set as the actor's RootComponent - picking one arbitrarily

Here is my what’s being called:

void AGraphActor::DrawVertex()
{
	auto ChildActor = NewObject<UChildActorComponent>(this, TEXT("VertexActor"));
	ChildActor->SetChildActorClass(VertexActor);
	ChildActor->CreationMethod = EComponentCreationMethod::UserConstructionScript;
	ChildActor->AttachToComponent(GetRootComponent(), FAttachmentTransformRules::KeepWorldTransform);
	ChildActor->RegisterComponent();
}

and in AGraphActor I set the root component:

AGraphActor::AGraphActor()
{
	USceneComponent* SceneRootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("Root component"));
	SetRootComponent(SceneRootComponent);
}

I’m not sure what is causing this error given that the parent actor has a root component.

I am still having this problem.

I’ve had this warning before too - it’s annoying but shouldn’t matter in the scheme of things - the log doesn’t happen in shipping builds.

Is your VertexActor a Blueprint Actor? If so you may be able to fix it by getting the USimpleConstructionScript from it and calling “FixupRootNodeParentReferences()” and “ValidateSceneRootNodes()”…

Thank you @RecourseDesign for the advice. I’m not familiar with where/how to grab USimpleConstructionScript so that I can call those methods. Could you provide an example?

No problem, the documentation for that class is at:

https://docs.unrealengine.com/4.26/en-US/API/Runtime/Engine/Engine/USimpleConstructionScript/

The code to call those methods (assuming you have a pointer(reference) to the VertexActor):

UBlueprintGeneratedClass* bpClass=Cast<UBlueprintGeneratedClass>(MyVertexActorPointer->GeneratedClass);
if(USimpleConstructionScript* sConScript=bpClass->SimpleConstructionScript) {
	sConScript->FixupRootNodeParentReferences();
	sConScript->ValidateSceneRootNodes();
}