x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Random Stream in Character; Seed has no effect?

Hello, I'm on 4.21.2.

On the level blueprint I add a Random Stream variable, then on BeginPlay, PrintString a random integer from that stream. When I change the Initial Seed in my stream variable parameters, then the random integer is different on startup. That's the behavior I expect.

Now, if I do the exact same thing, but in the Character (for instance, in a blank 3rd person template, in ThirdPersonCharacter), then the Initial Seed has no effect. No matter the value I set it to, I will get the exact same integer from my PrintString.

Is there a reason it behaves differently in a Character, or might this be a bug?

EDIT

If prior to using my Random Stream variable I set it using a Make Random Stream node, then changing the Initial Seed in the Make Random Stream node does produce the same behavior as in the Level BP.

So my question really is - why can't I use Initial Seed default value of the variable when in a Character BP?

Product Version: UE 4.21
Tags:
more ▼

asked Jan 26 '19 at 08:00 PM in Blueprint Scripting

avatar image

FPSYX
6 1 3 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Seed is a sequence distrubution that given value of initial stream. Random stream would call same sequence of distrubutions if you do not change initial seed. Therefore, invoking SetRandomStreamSeed to assign new value into your Initial Seed as property in your struct.

alt text

SetRandomStreamSeed on Blueprint API

more ▼

answered Jan 27 '19 at 12:35 AM

avatar image

Khubur
145 7 11 13

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Yes, I know what streams are. But why doesn't it behave correctly when you change the initial seed in variable parameters, in a character BP? Why only when you set it through a node?

more ▼

answered Jan 27 '19 at 09:03 AM

avatar image

FPSYX
6 1 3 4

avatar image Khubur Jan 27 '19 at 11:38 PM

Because setting of a variable initial seed is not generating a sequence. You need to override that distribution again.

avatar image FPSYX Jan 27 '19 at 11:50 PM

But then, why does setting of a variable initial seed work in the Level BP, and any other Actor BP, but not in Character BP? That's what I'd like to understand. Why does it behave differently in that specific class?

avatar image Khubur Jan 30 '19 at 09:49 PM

Character is just derived instance of Pawn class. Therefore Pawn is a AActor so I can't see any expectation of not working changing seed effect in character blueprint class. Check your implementation. Please check your communication between character or make sure that you call correct Stream struct you change on. Seed is independent of character blueprint classes. After that that is what recommended on documentation page of Random Streams;

To set the Initial Seed property directly on the variable, the RandomStream(instance of your struct) variable must be exposed for editing.

Random Streams on Unreal Offical Doucmentation

avatar image FPSYX Jan 31 '19 at 10:09 AM

Thank you for trying to help, but why don't you try it for yourself, see if you get the same result? Takes less than 5 minutes.

Start a new project, using 3rd Person template, no starter content. Open ThirdPersonCharacter BP, and do the following.alt text

You'll notice that whatever you set Initial Seed to before PIE, you get the exact same result.

Do the exact same setup in Level BP or Actor BP, and you'll get a different result if you change the Initial Seed. (As I would expect it to be.)

rstream.jpg (392.3 kB)
avatar image Khubur Jan 31 '19 at 01:53 PM

It is expected behavior I think you misunderstood what is sequentical access happens on streams. Stream is distributed numbers of given sequence that can be calculated for can be accessed in given sequence.

I printed out that number again and accessed second generated nubmer from stream. alt text

You might call Random Integer In Range if want to get random number between min and max numbers:

alt text

Sequentical Access

avatar image FPSYX Feb 04 '19 at 06:08 PM

I have not missunderstood sequential access.

For example, for a random integer in range 0-10 from stream :

  • If Seed 0 generates 3, 6, 1, 5, ...

  • And Seed 1 generates 4, 7, 8, 9, ...

With the following BP

alt text

  • in the Level BP for Seed 0 I get 3 and 6, for Seed 1 I get 4 and 7.

  • in the Character BP for Seed 0 I get 3 and 6, for Seed 1 I STILL get 3 and 6

In the Character BP I always get 3 and 6, whatever the seed is. I want to know if there is a reason for that, and if so why. And if there is no reason it might be a bug.

rstream1.png (86.0 kB)
avatar image Khubur Feb 05 '19 at 12:33 AM

Your solution is invoking the default value of initial seed is not overrided. Also Level Blueprint is different blueprint that assigns automatically assings initial seed value for stream generated objects. That's all you need to setup like in image.

alt text

Initial value will be overrided for each generated distribution on Begin Play event.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question