Is there something special you need to do when you change the root component of an actor?
I changed the rootcomponent of my cameraclass and it changes the root component (I guess) and but it also adds another one.
This is the constructor
AEnlightCamera::AEnlightCamera(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
//Setup root component
this->SetRootComponent(ObjectInitializer.CreateDefaultSubobject<UArrowComponent>(this, TEXT("Arrow")));
// Create a camera boom...
CameraBoom = ObjectInitializer.CreateDefaultSubobject<USpringArmComponent>(this, TEXT("CameraBoom"));
CameraBoom->AttachTo(RootComponent);
CameraBoom->bAbsoluteRotation = true; // Don't want arm to rotate when ship does
CameraBoom->TargetArmLength = 1200.f;
CameraBoom->RelativeRotation = FRotator(-80.f, 0.f, 0.f);
CameraBoom->bDoCollisionTest = false; // Don't want to pull camera in when it collides with level
// Create a camera...
GetCameraComponent()->AttachTo(CameraBoom, USpringArmComponent::SocketName);
}
I made a blueprint that inherits from my class and this is what I get:
I think this->SetRootComponent(ObjectInitializer.CreateDefaultSubobject(this, TEXT("Arrow"))); confuses reflection system try to initiate arrow component in diffrent varable (same as you did with CameraBoom) and then set it as rootcomponent, you can do that just by doing this RootComponent = ArrowComponent;, component initiation procedure just by that will figure that arrow component is root.
but it didn’t change anything. So what I did was got rid of the Ubox and put a normal object to the root component like a static mesh instead(maybe your camera component would work), to see what would happen, Built it (just let it hot load)and there was no double mesh(root component)!?
I put the ubox back as the root instead of the mesh and hot loaded it again.The double root appeared again but Mesh was still as the top root O.O but the bottom root object was the Ubox . I shut down my UE editor and re built and started without debugging. Lone behold no more double root!
Might have something to do with the order like creating a root AFTER you attach the code to the blueprint ect …but i could be wrong.
All in all it just seems like an aesthetic issue/bug