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. Dismiss Notice

Question Spawn particles over time?

Discussion in 'Visual Effect Graph' started by Duncano, Feb 12, 2022.

  1. Duncano

    Duncano

    Joined:
    Feb 2, 2017
    Posts:
    3
    Really struggling to get particles to spawn for a set period of time, and then stop spawning.

    Essentially I want them to spawn for 1 second only.

    Any help massively appreciated...i would have thought this would be a common requirement for any particle system.

    Got excited when i found the 'set spawn time' node, but bummed out, when i realized there was no input field. thanks.
     
  2. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,009
    You can control it from outside by stopping VFX by script, after one second passed.

    There is probably a second way, implementing your own spawn block (VFXSpawnerCallback), I tried to find some info on how to use it but could not.

    If you find something please share.
     
  3. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    306
    Hi. The best way to do it would be to use the loop system in spawner contexts. Basically set you spawn context to run for 1 second and then stop (so 1 loop of 1 second). This can be set from the spawn context inspector.

    upload_2022-2-14_10-33-31.png
     
  4. Duncano

    Duncano

    Joined:
    Feb 2, 2017
    Posts:
    3
    Thanks, i stumbled across the above solution on a different thread, its a really simple and nice way of handling it...it makes total sense. I am surprised its not more widely documented, i have been searching ' spawn time'...and the solutions that came back where mostly script based. I suppose the language / ui im used to is from 3D packages, when you generally set a start and end frame for spawning....so i was probably looking too hard for something similar. Loop duration and loop count is brill, and exactly what i need. thanks again!
     
  5. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,009
    Is there some kind of event signaled when the VFX finished spawning and there are no more particles ?
    I would like to use this event for destruction of prefab or signaling other operations.
     
  6. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    306
    Doc is here: https://docs.unity3d.com/Packages/com.unity.visualeffectgraph@10.8/manual/Context-Spawn.html

    You can check the sleeping state of a given system using https://docs.unity3d.com/ScriptReference/VFX.VisualEffect.GetParticleSystemInfo.html
    From 2021.2 onwards, we added a method directly in VisualEffect API https://docs.unity3d.com/2021.2/Doc...rence/VFX.VisualEffect.HasAnySystemAwake.html
    Note that sleep state won't work yet for some experimental features like strips or GPU events.
     
    koirat likes this.
  7. jitterware

    jitterware

    Joined:
    Mar 31, 2018
    Posts:
    4
    Cheers! I was searching for over an hour for this solution! Works perfect!