Unity Visual Effect Graph ( Set Spawn Event Age, Alive, Alpha )

I am analyzing the blocks and I do not understand the use of these … could someone define it well? … would help all interested … thank you very much

Hi @alexandroibarcena ,

The SpawnEvent attributes added to the Spawn context are attributes which you can inherit in Initialize. In the following example, we have a system which spawns periodic bursts of particles. In the Spawn context, we’ve added a Set SpawnEvent Color block to pick a random color between (0,0,0) and (1,1,1). Then in Initialize we have an Inherit Color block which inherits the random color value we set in the spawn context:

This allows us to calculate a single random color and assign it to all particles spawned in that frame as opposed to calculating a random color per particle if we were just using a Set Color Random block in Initialize.

Inheriting Source attributes is also useful when setting attributes via C# (there’s an example towards the end of the docs here) or when you use GPU events.

As for the actual attributes in your screenshot, here is what they do if you inherit/use them in the system:
Age - the age of the particle. If it exceeds its lifetime, the particle is typically killed in Update (though particle reap can be also disabled).
Alive - if the particle is alive. Setting this to false generally means the particle will get killed off in Update. If you use this attribute in Output you can actually toggle the render of the particle, without permanently killing it.
Alpha - the transparency of the particle (for particles using a transparent blend mode).

Hope this helps

1 Like

THANK YOU VERY MUCH, I’M GOING TO DO SOME TESTS AND ANY QUESTIONS WRITE TO THE POST

1 Like

Hi @vladimirneykov. I came across a similar situation where I want to set the Alive attribute in Spawn, but I can’t quite get the attribute to work as expected. Here’s a simple graph to demonstrate :


I set all particles to be dead on spawn via the variable SpawnEvent Alive, so I expect to see no particles spawned at all. But instead, they still get spawned:
8270463--1083456--VFXGraphIsAlive.gif
Also, I made sure to enable “Age Particles” and “Reap Particles” in the Update Particle block*.*
According to your previous explanation:
Alive - if the particle is alive. Setting this to false generally means the particle will get killed off in Update. If you use this attribute in Output you can actually toggle the render of the particle, without permanently killing it.”

I have both Update Particle and Output Particle Quad inherit isAlive, but the particles are neither killed nor hidden on render. Am I missing something? Thanks in advance.

Why do you inherit it in ever block, it supposed to be used in initialization - I am not even sure if it supposed to be there.
However in fact this is good question it does not inherit it from spawn block, even if it’s intented, I consider this as bug.
Anyway as workaround instead of setting it in spawn you can just directly set it initialization.

Hi @lil_sichen ,

Nice catch, as @Qriva pointed out, this looks like a bug - I’ve logged it here.
Also yes, you cannot inherit values past the Initialize context, you should set them in Initialize and then the value will be present in your graph as a usual attribute value.

In the meantime as a workaround to your scenario, you can send your Spawn Event Alive value as a 0 or 1 value and store it in another attribute in the Spawner (using Mass in the gif below) and then inherit it in an attribute operator (by using Source as its location) and plug the value into your Set Alive block in Initialize (it’ll automatically cast the 0 or 1 to false or true):

Hope this helps! :slight_smile:

8271726--1083744--Unity_EealSi8BNJ.gif

1 Like

Thanks for logging the bug @vladimirneykov! I will use another attribute for now.
@Qriva . Right. I wasn’t aware that that inherit attribute does nothing beyond Initialize Particle here. Perhaps it shouldn’t be an option at all @vladimirneykov?
Anyways, for context, I’m trying to share the attribute across multiple Initialize Particle blocks, so ideally I don’t have to do that in Initialize Particle, and setting the alive attribute in Spawn certainly helps.

P.S. Get Attribute: mass doesn’t want to connect to SetAlive in 2022.1.8f1, HDRP 13.1.8. I’m using a Compare instead:8273040--1083987--VFXGraphIsMassAlive.gif

This still seems to be somewhat an issue in Unity 6.000+. Set SpawnEvent Alive (OFF) does not have an effect on blocks within that same SpawnEvent context. Example, if you use an Output Event Handler, setting SpawnEvent Alive to (OFF), has no affect. Anything reading those blocks within that SpawnEvent context still gets passed out to the Handler.

Additionally, if the SpawnEvent is the Source, if that SpawnEvent Alive is set to (OFF), why does there have to be another Set Alive (from Source) in the Initialize context? Shouldn’t the SpawnEvent Alive automatically dictate what happens down the chain by default? Or am I missing something.

Thank You.