Search Unity

Resolved Trigger event(s) to do [something] inside VFX graph

Discussion in 'Visual Effect Graph' started by raaan127, Sep 6, 2022.

  1. raaan127

    raaan127

    Joined:
    Dec 9, 2019
    Posts:
    31
    Hello,
    I am looking for a way to manipulate a VGX graph system, like:
    - Trigger an event to kill all/some particles
    - Trigger an event to change size, alpha, etc...
    Is there a way to do so?
    upload_2022-9-6_18-38-41.png

    The event node I found only tied to a spawn node and I don't know what to do with it (I have very little experiences of coding).
    I only found tutorial to trigger event to spawn more particles
     
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,307
    There is no way to do this with events, but it's possible to create event like behaviour with property.
    Create boolean property in blackboard, implement your logic and run it when property is true. For example when it's true then set color to red, otherwise set to current color (nothing changes). If you are on unity 2022 this should be even easier as boolean port where implemented in blocks.

    Remember to reset property value to false in the next frame, so it does work once.
     
    Marie_G and raaan127 like this.
  3. raaan127

    raaan127

    Joined:
    Dec 9, 2019
    Posts:
    31
    It there a way to get VFX time within VFX Graph right when the bool is activate and store it as a float to use later?
    I was thinking about this node but havent found a way to use it.
    upload_2022-9-7_9-4-31.png

    btw, is it able to change bool within VFX Graph?
     
    Last edited: Sep 7, 2022
  4. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,307
    Right now I am not aware of any way to store or update blackboard property from inside the graph, however you can store it in one of particle attributes. If you need only one value per all particles then it's a lot of duplicated data, but it should definitely work and if it's just one float it should be fine. Whatever makes your job done :D
     
    raaan127 likes this.
  5. Marie_G

    Marie_G

    Unity Technologies

    Joined:
    Mar 9, 2021
    Posts:
    76
    Hi!
    You can try this method, or use directly the output of the branch.
    If your bool is set to false, you will get 0, if it's true you will the TotalTime value
    The bool can be replaced by the boolean property you have in your blackboard.

    upload_2022-9-19_18-43-22.png



    You can do that by using a compare node. In that example, the bool will be set to true when TotalTime is superior to one.
    You can change the condition of the compare node to fit your needs
    upload_2022-9-19_18-45-57.png
     
    sivrikaya likes this.
  6. Marie_G

    Marie_G

    Unity Technologies

    Joined:
    Mar 9, 2021
    Posts:
    76
    Examples on Unity 2021.3
    Slept a bit on this, you can send information using events via SpawnEvent Attributes in the Spawn Context
    https://docs.unity3d.com/Packages/c.../manual/Block-SetSpawnEvent.html?q=spawnevent
    But it will only affect new particles as this informaitonc as only be read in the initialise context with a Inherit node.
    upload_2022-9-20_0-19-33.png

    Using the same principle, you can use this data with a Boolean to affect other options: (or directly enable/disable blocks if you are on 22.2 or higher) In this example I used the TargetPosition to store the data as it's not used anywhere in the graph so it won't cause any issues.
    upload_2022-9-20_0-21-1.png

    Limitations:
    Inherit only works in initialize, you cannot use it to affect already existing particles
    Custom attributes are not implemented in SpawnEvent

    Hope this helps a bit.
     

    Attached Files:

    raaan127 and sivrikaya like this.
  7. sanliuk

    sanliuk

    Joined:
    Oct 1, 2022
    Posts:
    2
    i would like to apply another particle system when the first particle system hit a box( collisoin box on update)
    How can I make it?

    Event trigger could do this but there's not the option anymore
     

    Attached Files:

    Last edited: Jan 4, 2024