Search Unity

Question Start delay, kill vfx graph after number of seconds

Discussion in 'Visual Effect Graph' started by baltusquinn, Oct 2, 2022.

  1. baltusquinn

    baltusquinn

    Joined:
    Sep 29, 2022
    Posts:
    8
    Hello im trying to make some fireworks with vfx graph in HDRP But i want to start the fireworks after its awake and i want to kill the vfx graph after a number of seconds. please help.
     
  2. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    AlejandroHaibi likes this.
  3. baltusquinn

    baltusquinn

    Joined:
    Sep 29, 2022
    Posts:
    8
    I just started, could you explain a little more clearly? i'll add photo's
     

    Attached Files:

  4. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    To do that you can remove the string "OnPlay" which usually is in this field from here, this stops the effect from being automatically started.
    upload_2022-10-2_15-13-44.png


    For that you should write a c# script which controls the effect. In that script you the use what I posted above in the link. On the page in the link the first example underneath shows you how to trigger the default visual effect play event once every second. You'll have to change some things around but it has what you are looking for, a timer after which "play" is called on the event and in a very similar way you can wait again for an amount of seconds until you stop the event.
     
  5. baltusquinn

    baltusquinn

    Joined:
    Sep 29, 2022
    Posts:
    8
    okay i'll check i will reply when it worked
     
  6. baltusquinn

    baltusquinn

    Joined:
    Sep 29, 2022
    Posts:
    8
    it doesn't work im really bad with scripting sorry, can you maby like copy the script or something and say (your object) something like that..
     
  7. baltusquinn

    baltusquinn

    Joined:
    Sep 29, 2022
    Posts:
    8
    where it's needed
     
  8. baltusquinn

    baltusquinn

    Joined:
    Sep 29, 2022
    Posts:
    8
  9. baltusquinn

    baltusquinn

    Joined:
    Sep 29, 2022
    Posts:
    8
    Yea it rlly doesnt work
     
  10. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,307
    If you can't make it work just create new simple graph, connect custom event to trigger it and write script that sends that event, then when this works just do the same to more complex graph.
    The most simple script:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.VFX;
    3.  
    4. public class Container : MonoBehaviour
    5. {
    6.     public VisualEffect vfx;
    7.     public string eventName = "OnCustomEvent";
    8.  
    9.     public void Start()
    10.     {
    11.         vfx.SendEvent(eventName);
    12.     }
    13. }
     
  11. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    326
    Hello, you shouldn't be needing scripting or custom event for what you want to achieve.
    Just set the spawner of the parent system to run for a single loop of fixed duration:
    You can also add a start delay in the spawner.
     

    Attached Files:

    Last edited: Oct 4, 2022