Search Unity

Spawn over Distance seems to be linked to velocity ?

Discussion in 'Visual Effect Graph' started by VincentAbert, Jun 16, 2020.

  1. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    123
    Hello everyone, I have two questions about the following graph, which kind of works, but with two unexpected behaviours :
    - The first one is that the Spawn over distance input seems to be linked to the object velocity. If it goes faster it clearly emits more particles, whereas it is my understanding that it should only be linked to the actual movement distance ? Since it is a bit of a problem in my situation, I'd like to fix it...

    - The second one is more something I don't understand than an actual problem : as you can see I am lerping between the target position and the old position, so that it creates a continuous line. But I had to convert the target position to World Space (and not the oldPosition !) for it to work, which is very weird, why wouldn't they be in the same Space ?



    Thanks a lot for your help !!
     
  2. VladVNeykov

    VladVNeykov

    Unity Technologies

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

    Can you repost the image? It doesn't look like it attached correctly.
    To your questions, yes, Spawn over Distance is spawning based on the distance traveled over a period of time.

    If you want to spawn purely based on the distance between two positions, you can plug two Position or Vector3 properties into a Distance node, then multiply it by some rate, and use that as your Spawn Rate:

    This way you will have a steady "density" of particles which will be uniform regardless of the distance between the two positions.

    To your second question, I'm not really sure what's happening, but target and old position should be in the same space.
    If you have a small effect you can share which reproduces the issue, we can take a look.
     

    Attached Files:

    Rowlan and FlightOfOne like this.
  3. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    668
    Hi, Are you setting the start position from a script?
     
  4. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    In the example I shared we just have two inline Position operators and I'm moving one of them in the Scene view. No script. But yes, in a practical example you'd most likely want to expose the positions in Blackboard and set the values from script.
     
    FlightOfOne likes this.
  5. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    668
    Ah I see, makes sense. I forgot that there is gizmos! Thanks!
     
    VladVNeykov likes this.
  6. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,274
    Do you have an idea why this wouldn't work for me? It doesn't spawn anything at all:

    sp.png
    But the more interesting question is: Why do you see values in eg the position and capacity? I don't see anything at all. Makes it very hard to find errors. How do you "debug" issues like that? Using 2022.1.0b10.
     
  7. VladVNeykov

    VladVNeykov

    Unity Technologies

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

    Both Position nodes you have are at (0,0,0), so your distance will be 0 and so will be your spawn rate.
    Change one of your positions to be a different value so you get some distance between them.

    Your system is in world space, while the operators you are connecting are in local space, so we display "-" to show that the values are being converted. If you set your system to Local space, or change your Position nodes and the Set Position (Shape:Line) block to be in World space (i.e. have everything in the same space) you should see the direct results as no space conversion is being done.
     
    Rowlan likes this.