Random not Random

Discussion and feedback on Construct 2

Post » Sun Jul 21, 2013 5:29 pm

I have an issue with random() in that the results returned are the same on every run of the game.

So any items using random will reproduce the exact same numbers everytime the browser is refreshed, hence the gameplay isnt random.

Is there a random seed or some other way to produce more random numbers.

Thanks
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180

Post » Sun Jul 21, 2013 5:31 pm

Random is random, so you're probably just doing something wrong in terms of using the results.

If you create a simple event to change the text of a text box every second to random(100) or whatever, does it work?
B
57
S
15
G
11
Posts: 912
Reputation: 12,596

Post » Sun Jul 21, 2013 10:19 pm

I use random in my own apps and I can assure you it's quite random.
B
10
S
3
Posts: 233
Reputation: 1,537

Post » Sun Jul 21, 2013 10:22 pm

Remember, Random returns a FLOAT value, so Random(100) could be 1, 1.323423, 1.233, 3, 99.39324324, etc.

I just tested with a Text object, and button. On button click set text to int(random(100)) and it get a random first number every refresh.
B
100
S
31
G
11
Posts: 1,552
Reputation: 21,522

Post » Sun Jul 21, 2013 10:59 pm

@ArcadEd

I think thats the problem in this case. Other tests do show it to be working as expected.

Thanks to all.
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180


Return to Construct 2 General

Who is online

Users browsing this forum: krew42 and 6 guests