Random Stream always returns same number when called

I’m using the time to make a random stream. I then set the seed variable and use it when I spawn actors to randomly generate their properties(but from a seed so the player can then find cool seeds to share or whatever).

But everytime the seed is called it always returns the same seed. So every single actor is identical and just spawns on top of each other. What am i doing wrong? I thought seeds were “predictable random” that would be the same every time when called, but every iteration(or call) would go “down” the list of numbers it generates, no?

halp

I just tried it, seems to work fine:

How do you get your random numbers? Do you use the WorldSeed directly or another variable? When you use the WorldSeed directly, it updates and the next random value will be different. But if you somehow reuse the initial value, you’ll have the same “random” number. What I mean is, the first will return different numbers, but the second will always return the same number:

I just plug it into a spawn actor from class, the bp then takes the seed to randomize it’s variables before spawn.

How do I update the world seed?

That’s exactly what I was talking about. Your WorldSeed is not modified when you spawn the actor. You feed the same WorldSeed value to every actor you spawn, and that’s why they produce the same results. You need to update the WorldSeed every time you spawn an actor.

Try using a [Seed Random Stream] node after you spawn each actor.

Hmm, it works but not what I want.

The seed is now completely random everytime. I’m trying to get it so the player can set a seed before the game start so they can have the same results if they wish. Thanks for your help thus far though.

Okay so two things you need to do to pass the “correct” seed to your functions, spawned actors or anything being used in a loop.

  1. Make sure any function using the seed or anywhere it is being passed is a direct reference to the seed. (Is ‘Pass-by-Reference’ marked as True?)
  2. Only use the first reference once and then every time it is used in a function or an actor pass that seed through the output and use it for the next input.
1 Like

Thanks @NOOBMANPLSHELP ! I was having this same problem myself in C++. Just forgot to pass by reference, so it was making a new copy every time I used it. Total noob mistake.

Glad I could help.