Why don't my random instance vairables work? [SOLVED]

Get help using Construct 2

Post » Thu Aug 28, 2014 4:01 pm

What I want is for a player to click on Sprite1 and the game to randomly take them either to Layout1, Layout2 or Layout3.
(Sprite_roll is the name of my instance variable)

Why doesn't this work?:
left button clicked on Sprite1 -- set Sprite_roll to random(3)
Sprite_roll=0 -- go to Layout1
Sprite_roll=1 -- go to Layout2
Sprite_roll=2 -- go to Layout3

but this DOES work:
left button clicked on Sprite1 -- set Sprite_roll to random(10)
Sprite_roll<5 -- go to Layout1
Sprite_roll>5 -- go to Layout2

I'm sure I'm missing something obvious but to me this looks like it should work.
Thanks for any help!
Last edited by skennel8 on Thu Aug 28, 2014 5:16 pm, edited 1 time in total.
B
3
Posts: 3
Reputation: 181

Post » Thu Aug 28, 2014 4:06 pm

skennel8 wrote:What I want is for a player to click on Sprite1 and the game to randomly take them either to Layout1, Layout2 or Layout3.
(Sprite_roll is the name of my instance variable)

Why doesn't this work?:
left button clicked on Sprite1 -- set Sprite_roll to random(3)
Sprite_roll=0 -- go to Layout1
Sprite_roll=1 -- go to Layout2
Sprite_roll=2 -- go to Layout3

but this DOES work:
left button clicked on Sprite1 -- set Sprite_roll to random(10)
Sprite_roll<5 -- go to Layout1
Sprite_roll>5 -- go to Layout2

I'm sure I'm missing something obvious but to me this looks like it should work.
Thanks for any help!

The "=" compare will not work, because random(3) will give you a number like 2.33434 or something like that. int(random(3)) or floor(random(3)) will set variable to normal numbers 0 or 1 or 2 or 3.
B
22
S
9
G
7
Posts: 421
Reputation: 6,543

Post » Thu Aug 28, 2014 5:15 pm

SWEEET! Thanks so much for your help! SOLVED
B
3
Posts: 3
Reputation: 181


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 16 guests