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"

[c++] Component not centered on actor

I have a custom actor with some components created on it, in C++:

     volume = CreateDefaultSubobject<UBoxComponent>(TEXT("Bounding volume"));
     RootComponent = volume;
     editorIcon = CreateDefaultSubobject<UBillboardComponent>(TEXT("Editor Icon"));

The volume here gets placed at the actor's origin, presumably because it's the root component. But editorIcon gets placed at the world origin, and the SetWorldLocation doesn't seem to have any effect.

How can I make sure additional components get centered on my actor?

Product Version: UE 4.14
more ▼

asked Apr 15 '17 at 05:07 PM in C++ Programming

avatar image

28 2 3 9

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

After some more looking around, I found this solution to work:

editorIcon->AttachToComponent(volume, FAttachmentTransformRules::SnapToTargetNotIncludingScale);

more ▼

answered Apr 15 '17 at 05:24 PM

avatar image

28 2 3 9

(comments are locked)
10|2000 characters needed characters left

My guess is that during construction the actor has no position yet, so its position would be 0,0,0 . I think what you need is to attach the component to the actor. I believe attachparent function is what you need.

more ▼

answered Apr 15 '17 at 05:22 PM

avatar image

219 4 3 4

avatar image gardenvariety Apr 15 '17 at 05:25 PM

Aah, I found the same answer at the same time as your comment. I'll accept this one, although it would be nice if you could include the code snippet as well. Well, it's similar, but actually I have no AttachParent method on my components ..

(comments are locked)
10|2000 characters needed characters left
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