So I have a Random Stream which is given a random stream, and I pass it around the various functions, but when I get to a For Loop which is meant to generate planets with random distances and random angles relative to the orbiting star, every single value is exactly the same through each iteration of the loop.
I initialise my seed function at the start of the level blueprint:
But I thought the idea of a random seed was that it generates a sequence e.g 1,2,35,2090 based on the range you supply to it, so why does it repeat the same number for every iteration of a loop? I would have thought that the seed would continue its sequence and as a result I would get a different value for each iteration, but retain the same sequence every time I run the game.
You need to set the seed once. It looks like you set the seed for each number you want to generate, which is not correct – once the seed is set, the same numbers get generated from then on. Setting it every time means you generate the same numbers every time.
Separately: You are currently depending on the evaluation order between “pure” functions “random integer from stream.” The evalution order between the three return values MAY CHANGE in some future version of the engine, and if so, the returned star system will change, too. To fix this, you need to use a control flow node between each value; for example, use three local variables; Set them each in turn based on a random output, then return the values of those three local variables in your function return value.
As found, unless the random stream is passed by-reference the function will make a new copy of it, thus kind of defeating the purpose. If I’m guessing correctly you’re passing the variable named “seed” (which is acctually a random stream) to the planet generating function on each loop iteration?