Search Unity

Question Set custom attribute in Spawn context?

Discussion in 'Visual Effect Graph' started by dgoyette, May 31, 2020.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    I'm trying to tag a batch of particles with a Group ID, so that later I can read that attribute and do something different in rendering depending on the batch. I was hoping I could create a custom "Set SpawnEvent Attrbute" node, to set this value, but I don't see any way to do something like that. What I want to do is very similar to setting the Tex Index of a particle:

    upload_2020-5-31_14-0-42.png

    Is there any way to set some property of a particle within a Spawn context, so that I can tell which Spawn context the particle was generated from? Technically, I could hijack Tex Index here, since I'm not using a flipbook for this VFX, but that feels bad to me.

    In short, I have a couple of different Spawn contexts in my graph all feeding into the same renderer, but I want one conditional branch in the system that does something different depending on which spawn context it came from. It seems there's a way to get/set custom attributes, but I don't see how to set it within a Spawn context.
     
  2. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    I see. Thanks. I guess it's not what I need, though. Or, maybe I just don't know how to use it properly. My goal was that all particles spawned in a "batch" would have the same value for some custom property. But that would require setting the value within the SpawnEvent section. By the time I'm in Initialize Particle, I won't know which SpawnEvent the particle came from. Thanks for clearing up the usage, though.
     
  4. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
  5. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    Oh, I'll take a closer look then. Maybe there's something about the Spawn block that lets me feed something into Initialize, from your reading of it. I'll see how it goes.
     
    florianhanke likes this.
  6. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    It sounds like it in his description and on the linked page: “EventAttribute Payloads are attributes that will implicitly travel through the graph from Events, through Spawn Systems, and that can be caught in Initialize Contexts using Get Source Attribute Operators and Inherit [Attribute] Blocks”.
     
  7. Tehenauin

    Tehenauin

    Joined:
    Oct 18, 2018
    Posts:
    43
    I stumbled upon this same issue and I think setting custom attributes in the spawn event is a missing feature. You can have work arounds like feeding in values, but that is a solution I don't like very much.

    My workaround for instance is, taking an existing attribute (in my case alpha) and using this instead. It can be overwritten in initialize if needed. That works, but isn't very pretty.