How to differentiate particles from different spawners that are connected to the same Init system?


I have this setup with two spawners, where I need to do slightly different things with particles from different spawners. I know that I can create 2 separate init systems, but the problem is that those systems are quite long and would be almost identical (difference like in one block) and this would lead to a lot of duplication.
In my case I would like to get some bool (or int) attribute that will flag my particles to indicate from which spawner they are coming from and how should I handle them in that one block. I tried custom attributes but it seems like I can’t set those in Spawn area.

Did you try to set just any attribute in spawn context, then inherit it directly to your custom attribute?
For example meshIndex (assuming it’s not used), set it to 0 in left one and 1 for right one, then compare in init and set bool you need.
You don’t need to inherit it for the whole system, you just need to read it from source and set to any attribute you want.

1 Like

Yeah this is what I’m doing right now - setting Tex index because I’m not using it, but it kinda ugly.

Hello, What you’re doing is how I would approach this. I’m curious, for you, what would look like a “clean” solution?

Is the fact to use a Built-in attribute?
Does the ability to set a custom attribute in the Spawn Context would answer this?

Thanks in adavnce :slight_smile:

2 Likes

Yeah,
I don’t really know all technical nuances, and why it’s not possible to do right now but it would be ideal. Because what if I need to use all built in attributes (edge case I know) or if someone else will look at my VFX graph - they would be confused why I’m setting position of particle based on texture or mesh index.

I also wondered why there is no way to create custom attribute in spawn context.
In real world setting one of existing attributes was enough so far, but I can imagine this could be problem when those are used, plus let’s be honest I can’t call it “clean” solution. In case someone had to ready my graph it would be way more readable if all variables/attributes could be named properly.

On top of this, I think it was problematic when I needed to create custom spawner as there was no way to use custom variables - I had to stick to existing attributes, but using them makes them unavailable for other things.

Thanks to you and @Qriva for your inputs. We’ve been discussing the ability to create custom attributes in the Spawn Context. This makes a lot of sense, as it’s already possible to do it when setting the Event Attribute Payloads.
I talked to the team to see if some work already started on this. Thanks again.

2 Likes