Send an Output Event on Particle Death

Hello,

I have a VFX Graph that basically throw a particle with a certain velocity, and I want to send an event to a C# script when this particle dies by colliding with an object.

So I used the Collide with Sphere node that makes the particle lose its lifetime on collision, which works great, but I wanted to know if there’s a way to link an Event on die with an Output Event, or maybe is there another solution to get the same result ?

Thanks

This is currently not possible.

As said @Qriva this is not possible. “Output Event” are handled by the CPU while “GPU Events”, well… it’s in their name.
With this being said, you can do some workaround to depending on your use case.

-In the “Spawn Context” of your Parent system, you can set a “Spawn Event Lifetime”.
8874801--1211937--upload_2023-3-14_9-32-39.png

-In the “initialize Context”, use an “Inherit Source Lifetime”. This way, your particle lifetime values will be set thanks to the values that you previously set in the “Spawn Event Lifetime”.

-From your parent “Spawn event” link a new “Spawn Event Context” with a single burst. By default, this new Spawn will be fire as soon as the parent, but you can add “a delay”. This delay will be the “lifetime of your Parent particle”.

-Now, from this newly chained Spawn Context, you can wire an “Output Event”. Setup this way, the Output Event will be fired with a delay corresponding to the “lifetime” of your Particle. This Output event is triggered when the particle dies.

But in your case, you want to die on collision. So what you can do instead of using “Velocities” to drive your particle movement is to use its lifetime and Basic Lerp operation.

I’ve been doing this for this VFX and it worked great. I’m lerping from the (0,0,0) local space of the VFXGraph to an exposed “Target Sphere” properties. To interpolate between the two position, I’m just using the “Age over lifetime” operator. This way, I know that my particle will be at the Sphere center when its lifetime reach 1.0.

Et voilà. You can get really creative with your lerp operations and even add some rotation along the path.
8874801--1211952--upload_2023-3-14_9-53-47.png

The result is this:
One System “Head Projectile” is spawn, this particle lerp from VFXG position to my Target over its lifetime.
With Trigger Events and “GPU event” in the “Update Context”, this particle is spawning a trail along the way.
With Trigger Event and “Gpu event” on Die it Trigger a bunch of Other Systems.
The Output Event is used on the “Target Sphere” to Animated its material.
8874801--1211958--upload_2023-3-14_9-57-54.png8874801--1211961--vlc_nBJPhHkS08.gif

Note that it’s a workaround. It’s not perfect and has a lot of limitations. But you can still achieve very nice effect and Send your Output Event. Hope this was helpful. Have a great day.

2 Likes