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: 36
Reputation: 686

Post » Sun May 24, 2015 9:32 pm

I would use a boolean variable and the toggle function.
B
49
S
14
G
3
Posts: 540
Reputation: 5,611

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
...busy learning Unity - real lights etc!
(but c2 is easily the quickest way to make 2d html5 games)!
B
60
S
15
G
51
Posts: 2,086
Reputation: 33,692

Post » Wed May 27, 2015 6:36 pm

Cool. Thanks.
B
10
S
2
Posts: 36
Reputation: 686

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
79
S
24
G
54
Posts: 4,749
Reputation: 40,761

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

Post » Thu Sep 10, 2015 8:42 am

random(1,3)=

Image

round(random(1,3))=

Image
Image
B
55
S
23
G
7
Posts: 1,409
Reputation: 10,422

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

Return to How do I....?

Who is online

Users browsing this forum: LeFuji and 20 guests