Spawn emitter at socket location

I’m a c++ noob, so please go easy on me.

I set up a sprint system for my third person game. I created a particle system (called Sprint_Particles) to use as jet tails behind his feet, but I’m not sure how to add it. I’d like to spawn an emitter at each foot (I’ve created sockets called RightFootSocket and LeftFootSocket).

I’ve been looking at SpawnEmitterAttached but I can’t quite figure out how to set it to use the player mesh or set it to use my particle system.

Thanks.

Any ideas on this one?

Hi,

At first, create a variable in your Pawn class, e.g.

UPROPERTY()
TSubobjectPtr<UParticleSystemComponent> MyParticle;

Then, initialize it in your Pawn’s constructor:

MyParticle = PCIP.CreateDefaultSubobject<UParticleSystemComponent>(this, TEXT("MyParticleName"));

//Attach PSC to socket
MyParticle->AttachTo(RootComponent, TEXT("MySocketName"));

//Reference to particle system asset
static ConstructorHelpers::FObjectFinder<UParticleSystem> ParticleSystem
	(TEXT("ParticleSystem'/Game/Environment/Particles/My_particle_asset_name'"));
	
//Set Particle system's template
MyParticle->SetTemplate(ParticleSystem.Object);
MyParticle->bAutoDestroy = false;

To get a reference to a particle system find it in content browser, and then Ctrl+C and Ctrl+V it into Visual Studio.
Then, you can activate and deactivate particle system depending on your needs.

However, it is usually better to have assets references set up via blueprints, since hardcoding assets isn’t very flexible.

Best,

Works perfectly. Thank you!

Actually, I do have one issue. The emitter seems to spawn at his pelvis, not at the socket. It also doesn’t seem to move relative to his foot. Have I got my sockets set up wrong?