AttachTo deprecated in 4.12, and avoiding StarterContent

Hey there,

This course is still amazing and I’m having tons of fun with it :slight_smile:

A couple of remarks about this session:

  • When attaching LaunchBlast to RootComponent, if you’re running on 4.12 and later you shouldn’t use AttachTo, as it’s deprecated now. The method is now split into two separate methods, AttachToActor and AttachToComponent. Thus you’ll probably want to do this instead:

LaunchBlast->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);

There is an interesting topic in the UE4 official forums about 4.12 Transition Guide, you might want to have a look at it.

  • I tried to avoid StarterContent as much as possible. Importing the whole folder again just to get a sphere mesh seems rather overkill to me… There is a basic sphere mesh that you can use in /Engine/BasicShapes/Sphere. In order to make it visible in your Static Mesh dropdown list, you’ll have to enable the engine content filter :

Hopefully this will help some people and give food for thoughts to the others :wink:


AttachTo will actually crash your game in version 4.15, at least if used in the constructor. You can use SetupAttachment() with the same functionality as AttachTo, but it is useful to know there is also AttachToActor and AttachToComponent; I did not get crashes with these; though adding the transform rule argument was slightly annoying.

Thanks for this. This section gave me a lot of trouble and there was no mention of any of this online. It’s odd that the code will compile if you use AttachTo(), but it doesn’t do anything–took me a long time to realize that was the problem.

For anyone working in 4.17, does the code refuse to compile if you try to use SetRootComponent()? I cannot find a mention of the function anywhere in the API documentation for Unreal.

Using SetRootComponent() in 4.17.2 works fine, I’m getting way more trouble for trying to use FAttachmentTransformRules.

Is there a newer solution to this issue? I tried every solution the comments on this post said and none worked. My unreal is currently on 4.21

Also I`m having an issue with the UParticleSystemComponent, it seems as if it has changed names or something, because when I add it to my code it brings up an error, would love some clarification on that too if possible.

1 Like

Solved my problem!
For fixing the problem with UParticleSystemComponent, all I needed was to add these 3 #includes in the projectile.cpp file:

#include "ParticleDefinitions.h"
#include "Particles/ParticleSystem.h"
#include "Particles/ParticleSystemComponent.h"
1 Like

Privacy & Terms