Random number between 2 values

Get help using Construct 2

Post » Thu Jul 17, 2014 12:31 pm

So simple and usefull command, how could i forgot this :D THANKS!
B
6
S
2
Posts: 14
Reputation: 478

Post » Thu Jul 17, 2014 12:36 pm

No problem, I didn't know about it til a couple of months ago either, it's made a ton of stuff so much easier for me!
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Sun May 24, 2015 8:29 pm

I had a question related to this...
choose (3,6) chooses randomly 3 or 6

what if I want it to pick 3, then 6, then 3 then 6, etc...

Is there a simple expression solution for that?
B
10
S
2
Posts: 37
Reputation: 688

Post » Sun May 24, 2015 9:32 pm

I would use a boolean variable and the toggle function.
B
53
S
16
G
8
Posts: 628
Reputation: 8,609

Post » Sun May 24, 2015 10:48 pm

@a678182f

If you don't want to mess with booleans but oscillate between 3 and 6, you could use:

Variable1 = (((Variable1 / 3) % 2) + 1) * 3
B
68
S
17
G
65
Posts: 2,182
Reputation: 41,304

Post » Wed May 27, 2015 6:36 pm

Cool. Thanks.
B
10
S
2
Posts: 37
Reputation: 688

Post » Wed May 27, 2015 7:00 pm

Or you could even do this if variable1 starts as 3 or 6.

variable1 = 9-variable1
B
85
S
27
G
85
Posts: 5,062
Reputation: 57,858

Post » Thu Sep 10, 2015 4:10 am

Is it possible to pick random value from an Array?

[0] = 10
[1] = 24
[2] = 32
[3] = 12
[4] = 8

how to do I put it?
I tried: Array.At(random(1-3)) it didn't work..
ps. want to random range [1-3]
B
9
S
2
G
1
Posts: 13
Reputation: 669

Post » Thu Sep 10, 2015 8:42 am

random(1,3)=

Image

round(random(1,3))=

Image
Image
B
60
S
23
G
7
Posts: 1,461
Reputation: 10,661

Post » Thu Sep 10, 2015 8:47 am

floor(random(0,2))

Set a random number into 0 and 1.
B
6
S
1
Posts: 49
Reputation: 500

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: bikachu, oosyrag, QuantumMMX and 1 guest