# Random number between 2 values

Get help using Construct 2

### » Thu Jul 17, 2014 12:31 pm

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

### » 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

### » 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
9
S
2
Posts: 36
Reputation: 656

### » Sun May 24, 2015 9:32 pm

I would use a boolean variable and the toggle function.
B
47
S
14
G
3
Posts: 539
Reputation: 5,559

### » 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
59
S
14
G
50
Posts: 2,072
Reputation: 33,037

Cool. Thanks.
B
9
S
2
Posts: 36
Reputation: 656

### » Wed May 27, 2015 7:00 pm

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

variable1 = 9-variable1
B
75
S
21
G
48
Posts: 4,663
Reputation: 37,191

### » 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
1
G
1
Posts: 13
Reputation: 519

### » Thu Sep 10, 2015 8:42 am

random(1,3)=

round(random(1,3))=

B
49
S
19
G
6
Posts: 1,346
Reputation: 9,244

### » Thu Sep 10, 2015 8:47 am

floor(random(0,2))

Set a random number into 0 and 1.
B
5
Posts: 46
Reputation: 317

PreviousNext