Search Unity

Question Getting Length/Magnitude of particle velocity vector as a float

Discussion in 'Shader Graph' started by Gryph0n, Sep 29, 2019.

  1. Gryph0n

    Gryph0n

    Joined:
    Jan 14, 2017
    Posts:
    1
    Hey all! I'm having a really frustrating problem that I don't fully understand.

    I have a butterfly particle system that uses vertex displacement to create wing flapping motion. This works great! Now, I'm trying to make the butterflies flap faster/slower based on their velocity.

    I've taken particle velocity from my output stream, turned it into a vector3 and am using the Length node (whose documentation SAYS it returns a single float) but I am absolutely not getting a float! I'm getting this value.



    If I ADD this value to the particle's color, it works perfectly! Particles that are moving faster are rendered as whiter/brighter than particles that are slower.



    However, when I plug in its output as a multiply to alter my time, I get an incredibly strange pattern that causes strange distortion.



    The thing is: I KNOW multiplying these nodes by a float (in this case, a public field input float for Flap Speed OR just a flat number) creates the intended behavior I want. So, clearly, Length isn't returning a float! I have no idea what's going on! Or how I could possibly GET a single float value from my velocity vector.

    All I need is a float of magnitude, or even an average of the greyscale image that length produces :(

    Please help shader wizards!
     

    Attached Files: