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. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Why does Random Number node have "Constant" option, and why is it the default?

Discussion in 'Visual Effect Graph' started by dgoyette, Jun 28, 2020.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    3,962
    This tripped me up today:

    upload_2020-6-28_0-44-51.png

    Random Number has a checkbox for "Constant", which causes it t return the same number every time it's called. I don't understand why I would ever want that, as it means I'm not getting a random number. But it's also checked by default.
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    3,962
    I think I probably understand this now. I was incorrect in my initial assumption that this node would always return the same value. It will, however, always return the same value for a given particle, no matter how often it is called for that particle. The "Seed" slot here seems to be added to the actual seed used by this node, where the other addend is the particle ID:

    upload_2020-6-29_1-28-58.png

    So, it seems that for any two particles, it's very unlikely that those two particles will produce the same random number using this node. However, for any single particle, this node will return the same number each time it's called for that particular particle.

    One example of why this is useful: You want to move all particles a certain amount each frame. Without "Constant", then this would cause each particle to move a different random amount each frame. But with "Constant" checked, particle 0 might move 1.45 units per frame, particle 1 might move -3.57 units per frame, etc.

    So, this is definitely useful, and probably won't cause anyone problems if it's used as the default. I must have misunderstood what was going on in my first post.
     
    dman8723 and florianhanke like this.