Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Master VFX graph render all bullets via the Graphics Buffers?

Discussion in 'Visual Effect Graph' started by CitronMaane, Dec 2, 2021.

  1. CitronMaane

    CitronMaane

    Joined:
    Nov 16, 2016
    Posts:
    15
    Hi!
    I've been trying to make a master VFX graph that managed all the bullets in the game using the Graphics Buffer feature to both get more into the Graphics buffer feature and the VFX graph in general.

    Based on the siggraph 2021 showcase of the feature, so many thanks @VladVNeykov, i'm sure the C# side of things are fine. Unfortunately I can't wrap my head around how to interpret the data.

    The weapon triggers an event. "OnShot"
    Graph01.png

    but it only shows one bullet at a time and all the bullets. Also it only shows the first bullet.
    SHots.gif

    I've tried to set the spawn of the bullets to the bullet count but then it spawns all the bullets every time the weapon shoots. However it does show the bullets - tho not correctly all the time. also when the amount of bullets increases it breaks altogether.
    SHots02.gif

    I feel like i've misunderstood something fundamental in regards to how to intrepret the VFX graph because it is not that complex of a graph!
     
    VladVNeykov and Onigiri like this.
  2. azmi_unity

    azmi_unity

    Joined:
    Dec 13, 2020
    Posts:
    60
    Try replacing particleId with spawnIndex.

    spawnIndex starts at 0 each frame, which should match your graphics buffer count.
     
  3. CitronMaane

    CitronMaane

    Joined:
    Nov 16, 2016
    Posts:
    15
    That was an amazingly quick response!
    I'll give it a go as soon as possible thanks!
     
  4. CitronMaane

    CitronMaane

    Joined:
    Nov 16, 2016
    Posts:
    15
    So the change worked, though it spawned the graphics buffer initial size, where every particle that has no data is just positioned at world zero point.

    I've added an uint "IsAlive" to the buffer to kill all the particles that does not correspond to a projectile.
    This unfortunately results in the first projectile being spawned.

    If I resave the graph during play mode the particles spawn as intended with one exception.

    Shots03.gif
    upload_2021-12-6_9-23-20.png
     
    Arnold_2013 likes this.