Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Particle effect not being destroyed

Discussion in 'Scripting' started by mystrymaster, Nov 5, 2019.

Thread Status:
Not open for further replies.
  1. mystrymaster

    mystrymaster

    Joined:
    Oct 30, 2019
    Posts:
    6
    The AttackFX(Clone) in this picture goes away when the particle is done playing
    upload_2019-11-4_22-13-19.png

    But the HitFX (Clone) sticks around after, and I am left with this
    upload_2019-11-4_22-13-49.png


    I am calling them both what looks to be the same to me
    upload_2019-11-4_22-14-20.png

    I added the yield return null in there thinking I wasn't returning anything from the coroutine bit that didn't work either, any idea what I am doing wrong here?
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Couldn't you use a simple script on the instanced Particle object in your scene that checks in it's Update method if it's still playing, and if it's not, call Destroy on this gameobject? You could check isAlive, it should return false when the particles are no longer alive.
    https://docs.unity3d.com/ScriptReference/ParticleSystem.IsAlive.html
     
  3. mystrymaster

    mystrymaster

    Joined:
    Oct 30, 2019
    Posts:
    6
     
  4. mystrymaster

    mystrymaster

    Joined:
    Oct 30, 2019
    Posts:
    6
    So I figure this out, in case anyone happens upon this, I saved the prefab with the game object disabled, as soon as I enabled it, all behaved as expected
     
    brandav likes this.
  5. DancingZombie

    DancingZombie

    Joined:
    Mar 4, 2018
    Posts:
    6
    Make sure you set all child particle systems to destroy as well. A number of effects are made up of multiple particle systems.
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,620
    Make sure you don't necro really old threads please.

    The 2D forums are not even related to particles btw. I've moved it to the scripting forum.
     
Thread Status:
Not open for further replies.