Search Unity

Changing Color of Particles at Spawn

Discussion in 'Visual Effect Graph' started by woodwindblues, Mar 14, 2022.

  1. woodwindblues

    woodwindblues

    Joined:
    Nov 3, 2021
    Posts:
    4
    Hello,

    I made a particle system using the vfx-graph and would like to change the color-gradient the particles use at spawn time. Right now, when I change the color gradient in the output graph, the color for all existing particles changes. I only want newly spawning particles to have the new color, the already existing particles should keep their color gradient until they die.
    I tried putting a "Set Color over Life" block in the spawn node, but that did not work (the particles did not get rendered at all).
    Can someone help me out?
     
  2. VladVNeykov

    VladVNeykov

    Unity Technologies

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

    You almost had it; putting the block in Initialize was the right move, just change the Set Color over Life block to use Random instead of Over Life (as the lifetime will be 0 as the particles would have just been born, so you would always sampling the first bit of your gradient).
     

    Attached Files:

  3. woodwindblues

    woodwindblues

    Joined:
    Nov 3, 2021
    Posts:
    4
    Thanks! I was hoping to assign the gradient for the whole lifetime of the particles at spawntime, but it makes sense that only the first color of the gradient gets assigned. I guess I'll only use singl colors then.