UGameplayStatics::SpawnEmitterAttached issue 2

Hello. Maybe it is related also to this bug: UGameplayStatics::SpawnEmitterAttached issue - Programming & Scripting - Unreal Engine Forums

I found another issue: for local player FX is played once somewhere, for AI controlled and network clients FX is played fine. spawned particle should follow character when i is activated.

at postinitcomponents of actor i do:

ParticlePSC = UGameplayStatics::SpawnEmitterAttached(ovementEffects[i].ParticleFX, GetMesh(), AttachSocketName);
	if ( ParticlePSC )
	{
	    ParticlePSC->bAutoDestroy = false;
		ParticlePSC->bAutoActivate = false;
	}

then i activate it when needed with:

ParticlePSC->ActivateSystem();

And i see this particle only once and it is moving somewhere in some direction.

But if i add particle system component in class constructor like:

ParticlePSC = ObjectInitializer.CreateDefaultSubobject<UParticleSystemComponent>(this, TEXT("ParticlePSC0"));

and if i set same particle fx template in code or in editor, not metter - then it attached fine and follows the character as it should.

also, if you hit EJECT and select actor this particle is attached to, then go to actor details pannel and hit “set actor hidden in game” to set checkbox, then hit again to erase checkbox - then FX become to be visible and works fine like needed.

this is very strange issue and maybe i will need to providemore specifical info to reproduce it.

i think i found an issue.

UGameplayStatics::SpawnEmitterAttached(ovementEffects[i].ParticleFX, GetMesh(), AttachSocketName);

By default it calls bAutoDestroy = true if not overriden by function call. so FX was destroyed for local character but visible for replicated characters and i do not know why it is so.

Also FX activation was called at creation and then manual activation is not working, even if i call ActivateSystem(true); that is why FX was not visible for local character.

Additional test shows that if i set bAutoDestroy = false; after spawn and call DeactivateSystem() also - then i manually call ActivateSystem(true); and then FX works fine and it is visible.

With SpawnEmitterAttached, the comment for the function: “Plays the specified effect attached to and following the specified component. The system will go away when the effect is complete. Does not replicate.”

If you want to keep a ParticleSystem around, I suggest using CreateDefaultSubobject and storing the reference to it in the class. You can set the ParticleSystem to the component with MyParticleSystemComponent->SetTemplate( ParticleSystemAsset );

With that said, thank you for submitting a bug report, however at this time we believe that the issue you are describing is not actually a bug with the Unreal Engine, and so we are not able to take any further action on this. If you still believe this may be a bug, please provide steps for us to reproduce the issue, and we will continue our investigation.

Hello, Kyle Langley.Tnx for reply.
I can’t use PSC created in constructor because i need to use dynamically created particles based on some conditions and i can not predict how much components i will need, so i need to create it dynamically and store as array of PSC. Before, when i used CreateDefaultSubobject in constructor i never had problems, but dynamical particles works a bit different.

I think this issue happens because of 2 reasons:

  1. issue: UGameplayStatics::SpawnEmitterAttached issue - Programming & Scripting - Unreal Engine Forums
    so i can not set bAutoDestroy = false in creation call and particle fx was destroyed.
  2. I do not know but i thought ActivateSystem(true) where true - it is same as Activate(bool bReset), so system should be reset and strart to playing but it was not happens until DeactivateSystem() is called.

will be a good feature if UGameplayStatics::SpawnEmitterAttached will have parameter like bInstantActivation so i can just create PSC but activate and deactivate it later without a need to spawn and destroy it every time.

You can use CreateDefaultSubobject to store something and use it during run time. You do not need to rely on SpawnEmitterAttached.

Simply create a ParticleSystemComponent using CreateDefaultSubobject and give it a template with SetTemplate. Then, you can call Activate( ) on the ParticleSystemComponent during runtime (let’s say when a weapon fires) without needing to use SpawnEmitterAttached.