Hello, I have a spawned particle system that I’m trying to auto destroy.
It is snow falling, and after a certain period I want to be able for it to stop (when player moves inside a cave) and be replaced with another effect.
The problem is if I use SetActive(false), it’s ‘Kill on completed’ won’t trigger.
I want it to be able to destroy itself, so in the code I can immediately start up another ambient effect.
//.h UPROPERTY() UParticleSystemComponent* AirParticle; //.cpp //Spawning AirParticle = UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), snow, FTransform::Identity); //Set auto-destroy (doesn't work) AirParticle->SetActive(false); // Kill on completed doesn't work AirParticle->GetOwner()->SetLifeSpan(3); // Doesn't work because owner is 'WorldSettings' and not an actual Actor //Spawn new particle in place, while old one auto destroys itself AirParticle = UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), cave, FTransform::Identity);
Any idea what to do here?
I tried creating an empty actor so I could attach it and then set a lifetime on that actor, but I can’t get an empty actor to be created!
If I just change the variable to a new component, will the old unreferenced one be automatically garbage collected?