Just figured that the Projectile Destruction script is unnecessary

Use this instead:
image

Does this also remove the instantiated game object to which the particle system is attached?

Well, no, it just rids you of the gameObject which the ParticleSystem is a component of. You’d need to copy the components around.

The image is broken (at least for me) but yeah, all you need to do is use the overloaded Destroy(GameObject object, float time) method, where time is how long of a delay you want until the object is destroyed. No need to make another whole script just for that.

1 Like

The image shows the base ParticleSystem configuration, on the first config drop down, with “Stop Action: Destroy” selected. You can use the lifetime of the particle effect to determine how long its actual life should be.

There are a couple of ways to go about destroying a particle at the end of its lifetime, even if it’s Destroy(Instantiate(particleEffect),particleEffect.GetComponent().startLifetime), which admittedly just does what changing the settings does, but is good if you’re lazy and don’t feel like setting up your prefabs!

That seems like poor form, though. I’d rather just change the ParticleSystem settings in the prefab, and have the particle systems be responsible for destroying themselves, as in the picture.

In the case of the LevelUp effect’s prefab I would say one use for having the extra prefab “wrapper” around the imported SH_VFX prefab is that it allows changing the particle system’s setting without affecting the original prefab.
Of course one could just duplicate it and do whatever one likes so one would still have a prefab that has the particle system on its root gameobject…

Privacy & Terms