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.
remove the “OnPlay” string from the effect inspector, write a script which takes of the delay and the duration and calls on OnPlay and OnStop events yourself (or you could use timeline with the vfx track for this if you have that in the project anyway)
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.
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.
okay i’ll check i will reply when it worked
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…
where it’s needed
?
Yea it rlly doesnt work
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:
using UnityEngine;
using UnityEngine.VFX;
public class Container : MonoBehaviour
{
public VisualEffect vfx;
public string eventName = "OnCustomEvent";
public void Start()
{
vfx.SendEvent(eventName);
}
}
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.