Search Unity

[Solved] How to only turn off new particles?

Discussion in 'Scripting' started by Josiah_Ironclad, Apr 25, 2020.

  1. Josiah_Ironclad

    Josiah_Ironclad

    Joined:
    Sep 24, 2019
    Posts:
    156
    I have a ship that produces particles as an exhaust trail, and I want the exhaust to stop producing new particles when a certain condition is met, but I don't want to outright stop the particle system, because that would instantly turn off all current particles as well.

    Can only find threads and questions regarding turning particle system on/off.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,735
    You can adjust the rate over time value of the
    emission
    module of your ParticleSystem.

    It's common to have two separate values that correspond with OFF and MAX, and then according to your throttle setting, just adjust this value and set it into the rate over time.

    The emission module is actually a struct, so you have to copy it out of the ParticleSystem before you modify any properties on it.
     
    Josiah_Ironclad likes this.
  3. Josiah_Ironclad

    Josiah_Ironclad

    Joined:
    Sep 24, 2019
    Posts:
    156
    Thanks, that explains all the errors I was getting, didn't know about it being a struct.
     
    Kurt-Dekker likes this.
  4. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
  5. Josiah_Ironclad

    Josiah_Ironclad

    Joined:
    Sep 24, 2019
    Posts:
    156