Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Double Rootcomponent


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->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:

alt text

Product Version: Not Selected
untitled.png (13.9 kB)
more ▼

asked Feb 05 '15 at 05:15 PM in C++ Programming

avatar image

115 12 15 89

avatar image Dyronix Feb 06 '15 at 02:58 PM

I think I found out how the rootcomponent works now I have this:

... Some Code ... RootComponent = ArrowComponent;

... Some Code ... RootComponent = PlayerMeshComponent;

And now player mesh component is the rootchild of arrowcomponent. Maybe a bit more documentation for the assignment operators is needed here.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

I had the same issue and I was just now playing with it.

I even tried to simplify it by just doing

 RootComponent = PCIP.CreateDefaultSubobject<UBoxComponent>(this, TEXT("CollisionComp"));

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 :)

more ▼

answered Feb 05 '15 at 07:30 PM

avatar image

447 35 20 53

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Feb 05 '15 at 05:47 PM

avatar image

37.3k 936 172 1116

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question