AttachTo doesnt attach to

If i specify in c++
Gun = CreateDefaultSubobject(TEXT("Gun")); Gun->AttachTo(Mesh);
and Create an blueprint class that inherits from it it wont be attached to anything until i rename it. This seems to be a hot reload problem or a problem within the blueprints.

Hi ,

Thank you for the report. We have assigned one of our technicians to investigate your issue and they may post here with additional questions or comments.

Hey -

When you use the CreateDefaultSubobject you have to specify what type of object you’re creating. Using a static mesh component as an example:

MyMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MyMesh"));
	MyMesh->AttachTo(NewScene);

When you create a blueprint based on this class it will have the static mesh component attached to the NewScene component, which in this case is a SceneComponent that has been set as the root component.

Cheers

Sorry that was a typo.

Thats what i did.

It wouldn’t even compile otherwise.

For me the AttachTo() does nothing

AttachParent = …; works as intended though.(Mostly)

I am wondering why it is fine with the parameters i give it. namely only the object i want it to attach to, but it is unchanged in the hierarchy after compile.

I have to change it to AttachParent and then delete all binaries and compile again. It doesn’t change the hierarchy just with a hot reload.

Hey -

I’ve not yet been able to reproduce the issue. Just to make sure I’m following the same steps, I created a class based on Actor and added a scene component and static mesh component to the class. After setting up both components as described above in the constructor of the class I compile and made a blueprint from that class which had the hierarchy setup properly. Let me know if you are using a different approach or if you have different results using this method. If possible could you post the full class you’re using that is not updating the blueprint as well?

Hey -

We’ve not heard back from you in a few days. I will be marking this post as resolved for tracking purposes. If you’re still having issues with using AttachTo() you can add a comment to reopen this post and we will investigate further.

Cheers