AttachParent is private in UE 4.13!

I come from 4.12 engine version.

When switching to 4.13, I get these errors:

error C2248: 'USceneComponent::AttachParent': is private

How do I fix?

Hello gedamial,

This was a change made with 4.13 and these values are now accessed with Get functions rather than being accessed directly. Here’s an excerpt from the Release Notes:

New: SceneComponent AttachChildren, AttachParent, AttachSocketName are now private. Use GetAttachChildren/Parent/SocketName, AttachTo, or SetupAttachment as appropriate.

Hope this helps!

But the intellisense gives me this error if I use the function GetAttachParent()

I’m modifying. I’m assigning. I’m not just getting

Any news?

I’m trying to figure this out as well gedamial. The fps c++ tutorial doesn’t have an update for 4.13 for these new functions. I’ll post if I figure it out.

Okay I got something to work but I’m unsure if this is the proper way.

MainCamera->AttachTo(this->GetCapsuleComponent());
FirstPersonMesh->AttachTo(MainCamera);

“this” refers to “MyCharacter” so basically it is attaching the CameraComponent to MyCharacter’s CapsuleComponent.

Edit:
So apparently the docs state that K2_AttachTo is depreciated but not AttachTo for USceneComponent.

Op gets a warning using AttachTo when attaching a particle component to the root component.

The warning states to use AttachToComponent instead, but the release notes mention AttachTo.

Not sure what the proper usage would be here. I tried to use AttachToComponent in my project and it expected more than one argument, not sure how to use it though. Also in the comments for the function it states that SetupAttachment is preffered when a component is not registered but now SetupAttachment is depreciated!

So… Hopefully someone who knows about this will reply :slight_smile:

Try ParticleComp->AttachTo(RootComponent)

I get a warning

warning C4996: 'USceneComponent::AttachTo': This function is deprecated, please use AttachToComponent instead. Please update your code to the new API before upgrading to the next release, otherwise your project will no longer compile.

Hmm that’s interesting that they wouldn’t mention AttachToComponent in the release notes. I built my project with AttachTo and didn’t get that warning but…

If you look at the api reference USceneComponent
K2_AttachTo is depreciated but not AttachTo.

So, I’m gonna say go with AttachToComponent. Hopefully someone else will chime in here.

I might be wrong about this, but I had a similar compiler warning when using the various AttachTo functions. After some digging I found out that Component->SetupAttachment(ParentComponet) was the proper way to go.

Hello, I was out for the weekend so I’m just now seeing this. The reason the stuff about AttachTo and SetupAttachment weren’t mentioned in the 4.13 release notes is because that was actually changed in 4.12. Here’s an excerpt about it from the 4.12 release notes:

New: USceneComponent::AttachParent, AttachSocketName, and AttachChildren have been marked as deprecated as a bridge step to their privatization in 4.13.
USceneComponent::SetupAttachment has been added and is intended to be used in constructors instead of setting AttachParent and AttachSocketName directly.
USceneComponent::AttachTo now routes to SetupAttachment when called from a constructor.

From what I’m reading there, it does seem like flydecahedron’s implementation is correct, but it also seems that it’s doing the same as SetupAttachment when being called in the constructor.

So guys, to make a long story short so do I change this line:

MyComponent->AttachParent = BlaBlaBla;

To fit with the new API?

That’s correct. Setting the value directly was never the optimal workflow as far as I know. It may have been cutting some corners and causing some odd behavior in certain situations. This would explain why they made it private and forced people to change to using the attach functions to modify it.

Thanks for clarifying! I added notes to the fps c++ tutorial about the api change.

Also, for anyone else reading this my implementation won’t work if you need to offset the component.

Ok so how should I change my assignment/code?

MyComponent->SetupAttachment(MyParent);

I was running into the same issue and reading this topic.
So i looked at UE source to see how they attach components in the constructor and SetupAttachment seems to be the way to go

// Character.cpp line 100

Mesh->SetupAttachment(CapsuleComponent);