Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question getting spawnIndex to work with [Constant Spawn Rate] block

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

  1. raaan127

    raaan127

    Joined:
    Dec 9, 2019
    Posts:
    31
    Hello,
    I am trying to spawn particles on an arc.
    I want them to spawn one by one so I am thinking about using [Constant Spawn Rate] or [Periodic Burst]
    but it seems to work only when I spawn them all at once (with Count > 1. Cne by one is not working)

    I hope to know why it is not working.

    upload_2022-11-8_17-27-4.png
     
  2. PaulDemeulenaere

    PaulDemeulenaere

    Unity Technologies

    Joined:
    Sep 29, 2016
    Posts:
    146
    Please ignore my previous (deleted) message, sorry, I've been confused by our own implementation and what was exposed in the graph.

    The spawnIndex will return the index of the particle inside the current spawn event, in the case of a constant rate, you will receive a value between [0; amount of particles spawned this frame[

    Using a small constant rate, you won't have any value greater than 0 because the frame rate is greater than spawn rate:
    Spawn_Particle_On_Arc_spawn_index.gif

    Thus, you should use `particleId` in that case:
    Spawn_Particle_On_Arc_Constant_Rate.gif

    However, with a periodic burst, spawnIndex will be between 0 and 6:
    Spawn_Particle_On_Arc_spawn_index_burst.gif
     
  3. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    337
    I've run into that confusion before too and only now realized it.
    @PaulDemeulenaere Can you make this example be part of the documention please :)
     
  4. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,296
    @PaulDemeulenaere By the way, what about the that idea of "How to" page with the most common vfx scenarios, is it still planned/worked on?