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"

Create weather with random integers

Hi !

I created a weather system wich is intended to work this way : Every amount of time (here 5 for debugging purposes) the system cheks if it's raining or not. If not, a random integer is drawn. If this random int is greater than my "weather_change_cap" (=50) it starts to rain (and i'm playing the sound).

But it's not working. It is totally random : sometimes it's raining but the random int is 3, and sometimes it's not even if the random int is 78 (for example).

alt text alt text

Could someone help me please ?

Thanks !

Product Version: UE 4.18
Tags:
question.png (110.6 kB)
question-p2.png (98.4 kB)
more ▼

asked Feb 20 '18 at 11:29 PM in Blueprint Scripting

avatar image

Agonarlith
1 2 1

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Having the Tick and then a Delay is not good practice - That means that each frame, you create a delay of 5 seconds then do something. Therefore, after 5 seconds, your blueprint will be continually running through the code after the delay.

Also, why not random between 0 and 1 and then use that as your 50/50 chance?

alt text

capture.png (100.4 kB)
more ▼

answered Feb 21 '18 at 09:52 AM

avatar image

Dune
1.9k 52 39 200

avatar image Agonarlith Feb 21 '18 at 12:26 PM

Thanks for your help !

I made this 50/50 because at start it was "if my random int is > 80 ---> make it rain" but for debugging purposes, I lowered the value ! But I made it an other way, I draw a random int between 0 and 5 (included) and if my random int is equal to 4, then it's raining.

So, I managed to recreate your blueprint, so I've created a custom event which is called : when it's not already raining ; when my random int is not equal to 4 ; and at the end of my blue print.

So here's what I've got : alt text alt text

But it's still not working, I made a print between the first branch node and the second one in order to see which number was draw. But sometimes it draws 3 and it's starting to rain, and sometimes 4 and it's not raining... Event sometimes, it draws 3, nothing happens, it draws other numbers, and then it draws 3 again and it starts to rain.

I don't know if it's linked to the delay ? Or the Condition on the seconde branch node which isn't working ?

(comments are locked)
10|2000 characters needed characters left
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