Relative location broken for C++ created component

I just had a similar experience. I created a new character pawn that had a FlipbookComponent in c++.

Make sure you don’t forget to explicitly call the constructor in your ctor’s initializer list. You can use Super(ObjectInitializer). See APaperCharacter for an example.

Also, try restarting the editor.

I forgot to explicitly call that ctor in my class. I’m not certain that fixed it because my engine crashed when I was hotreloading the code, but when the engine booted back up the incorrect positioning resolved itself. So I’m not sure if the ctor fixed it or just restarting the edtior fixed the issue.

Had similar Problem. I solved it by putting ChildActor->CreateChildActor(); in OnConstruction!
Otherwise the ChildActor Location is not attached to its parent which should be ChildActorComponent

This issue seems to still be present in 4.24.

FIX: to prevent the issue with actor components not following the parent, the declaration must be private,
but using UFUNCTION(meta = (AllowPrivateAccess = “true”)) in the header file, and Component->SetupAttachment must be used after creating the default subobject during construct.
You might need to compile from scratch, close the editor and your IDE, delete the folders Binaries, Intermediate and Saved. Right click the uproject file, regenerate project files. Open the C++ solution and build your project (in the Development Editor configuration). Re-open the UE4 editor.

1 Like

Do I need to sell my sould to the devil as well in order to make this basic feature work?
Lmao thanks god I’ve stopped using this cumbersome mess and is using Unity if I have a mood to fiddle around with primitive game dev

Thanks for the answer though, hopefully it will be of great help to someone!

1 Like

UE5.2 here:

Closing down the editor and IDE and then deleting the Binaries, Intermediate, and Saved folders did the trick for me.