Particle doesn't follow pawn after Pawn.AttachComponent(ParticleSystemComponent)

Hi everyone. This question is regarding UDK–not UE4. (It seems like we have to say that now for the people who don’t see what forum they’re in.) I’m able to spawn a particle system component. I can see it just fine. But when the pawn moves, the particle system component stays put.

This is the code that spawns the particle system component:



var() ParticleSystem Particle;
var ParticleSystemComponent ParticleComponent;
var Pawn AttachedPawn;

function SpawnParticleSystem(Pawn P)
{
	ParticleComponent = WorldInfo.MyEmitterPool.SpawnEmitter(Particle,P.Location,P.Rotation);
	P.AttachComponent(ParticleComponent);
	AttachedPawn = P;
}


“Particle,” the first var I declare is an archetype that I set beforehand. I’m using this class to keep track of status effects on the characters in my game and each status effect has its own particle system. Except for that, I think everything else here is pretty self-explanatory.

Any idea what I need to do to get the particle system component to follow the pawn I’m trying to attach it to?

I figured it out. You can attach the particle system component at the same time you have the emitter pool spawn it:



ParticleComponent = WorldInfo.MyEmitterPool.SpawnEmitter(Particle,P.Location,P.Rotation,P);


And using “WorldInfo.MyEmitterPool.SpawnEmitterMeshAttachment” instead?

I haven’t tried using SpawnEmitterMeshAttachment. I suppose there’s some distinction between attaching to the pawn (or any actor, really) and attaching to the pawn’s (or other actor’s) mesh. Mostly I just needed an emitter at the same location, and SpawnEmitter seems to work well enough for that.