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

0 favourites
  • 3 posts
From the Asset Store
Tap the ball, control it, avoid touching spikes and score higher!
  • 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!

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • SWEEET! Thanks so much for your help! SOLVED

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)