Search Unity

Question VFX GRAPH - How to spawn particles by exposed variables (position, color, size, lifetime)

Discussion in 'Visual Effect Graph' started by spicyc, Nov 8, 2022.

  1. spicyc

    spicyc

    Joined:
    Jun 24, 2019
    Posts:
    1
    Hello, I am trying to utilize VFX Graph instead of Shiruken. However, I am having a hard time recreating the use case of .EmitParticle() with emit parameters in Shiruken.

    I would like to be able to set the position, color, size, and lifetime when spawning the particle. I want to 'pass' these values in and do not need to manipulate them once the particle has spawned (until death via lifetime).

    I have tried to do this through an exposed graphicsbuffer that contains an array of X. I was planning on doing this for the position, color, size, and lifetime, but I am thinking there has to be a better way to do this.

    Could someone weigh in on this? THANK YOU!
     
  2. The_Storm_Rider

    The_Storm_Rider

    Joined:
    Jan 28, 2020
    Posts:
    66
    What you are looking for is eventAttribute.SetFloat() or eventAttribute.SetVector3() when you use VisualEffect.SentEvent().
    Mind the difference between attribute and exposed properties. Position, color, size and so on are attributes, meaning they belong to a specific particles. Exposed properties are the same for every variables.
     
  3. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    SendEvent is the way to go for most cases however consider that you can only call SendEvent once per frame per visual effect. Your graphics buffer idea is still relevant for some cases: https://forum.unity.com/threads/multiple-event-burst-spawns-of-the-same-vfxgraph-possible.852049/
     
  4. The_Storm_Rider

    The_Storm_Rider

    Joined:
    Jan 28, 2020
    Posts:
    66
    fleity likes this.