Search Unity

Question Conditionally enable/disable nodes?

Discussion in 'Visual Effect Graph' started by dgoyette, Jul 3, 2020.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    I'm trying to make a visual effect that's somewhat reusable. For example, in some cases I want the particles to spawn along a line, and in other cases I want the particles to spawn on a circle. Ideally I'd be able to have the following two nodes in my graph, and just enable/disable them conditionally:

    upload_2020-7-3_14-40-8.png

    I don't see a way to do that, though.

    I see three fairly cumbersome options:
    • Pretty much completely duplicate my graph, with a different spawning behavior in each.
    • Move at least two chunks of the graph into subgraphs to somewhat avoid as much duplication.
    • Rebuild the Position (Line) and Position (Circle) logic manually and plug them into the general Set Position node.
    Is there another here that's not such a hassle? I'd be conditionally changing the behavior based on a public parameter to the visual effect.
     
  2. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Hi @dgoyette ,

    Toggling blocks is not possible at the moment, but it is next up on our public roadmap.

    In the meantime (a slightly convoluted work-around), you can set a position in one shape, store it somewhere else (e.g. in TargetPosition), then reset the position back to 0, set the new position in a new shape, and then blend between the two for an easy switch, which you can also expose and tweak from the inspector:

    (There's an improvement coming soon which would allow you to blend between shape blocks right away, so you could simply have a bunch of shapes after each other and decide which one would come on top).

    Hope this helps!
     

    Attached Files:

  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    Thanks for mentioning the Blend Position approach. That's very helpful. I hadn't thought of that.
     
    VladVNeykov likes this.