Component has local offset when spawn (located at world 0,0,0)

Use SetupAttachment instead of AttachToComponent, if you’re doing this in the constructor. Also, use the ObjectInitializer version of the Constructor. Not doing so nearly always causes headaches or random hard-to-track issues. e.g:



AMyClass::AMyClass(const FObjectInitializer& OI)
: Super(OI)
{
    	RootCmp = OI.CreateDefaultSubobject<USceneComponent>(this, TEXT("Root"));
	SetRootComponent(RootCmp);
}


Are you sure the Root Component isn’t also at world origin?

2 Likes