If I want to have a seeded random (RandomStream) in my GameState blueprint, and use that to generate random numbers across multiple Actor blueprints, how could I accomplish that?
I added a getter in my GameState, but everything that gets the seed generates the same value. I want multiple Actors to query the same RandomStream instead.
I could of course wrap the various random functions and ask the GameState for anything random I need, GameState->GetIntegerInRange, GameState->GetRandomBool, etc⌠But that seems like a heavy-handed solution to the problem.
There are already several functions available in blueprints that offer a random typed value of your choosing, and it appears that they come in pairs, one requiring a RandomStream input and one that does not. Iâd just feel weird implementing wrappers around these functions in my GameState that are nothing more than wrappers around the seeded version.
yeah, thatâs what i meant, you choose one and do other remapping out of the same source. i assume epic did what they did because of multithread reason, but it doesnât really block you from implement one that gets from a single stream.
I think this is because by default structs (like RandomStream) are passed around âby valueâ, which means a copy is made, and so the copy of the stream is being updated rather than the original.
this is pretty interesting, is there any other similar functions behave in this way in UE4 currently?
As makeRandomStream does not have tool tip said about this, so can we assume other function will just making copies by default?
I guess random is probably more confusing for programmers in say C, but to think of it in function calls in graph makes sense that itâs a copy instead of setting seeds for a global stream like in C.