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.
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"));
editorIcon->SetWorldLocation(this->GetActorLocation());
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?
After some more looking around, I found this solution to work:
editorIcon->AttachToComponent(volume, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
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 …