Create Random Objects

This forum is currently in read-only mode.
  • Hi,

    I'm making a top down shooter, and i've created this object to act as a box of items. When clicked the box will open to reveal a random powerup.

    I currently have two.

    Question is: how do I get it to be random(either powerup a, or powerup b)??

    Thanks a million!!

  • A 50/50 chance would be random(1), where the out come would be either 0, or 1.

    So if random(1) equals 0 do this,

    and random(1) equals 1 do that.

    Note each time you do a comparison using random it will generate a new number. If you want to choose from one "roll" you will need to save the out put to a variable first, and then compare the variable is = 1, or 0.

  • A 50/50 chance would be random(1), where the out come would be either 0, or 1.

    So if random(1) equals 0 do this,

    and random(1) equals 1 do that.

    Note each time you do a comparison using random it will generate a new number. If you want to choose from one "roll" you will need to save the out put to a variable first, and then compare the variable is = 1, or 0.

    Random(1) always equals 0. Random(2) would would equal either 0 or 1.

  • um, where do i find random?! i mean, is it in system?! or......?!

  • Oops.

    Ehhh zero based can be confusing, course not as much as 1 based.

    Perhaps I was confusing random(0) for random(1)... oh wait.

    um, where do i find random?! i mean, is it in system?! or......?!

    Its under the system>math>generate random number.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's an expression found in the system object. You use it to set values like this.

  • oh, dang, i don't have math in my system. i forgot to mention, I'm using a older version of Construct. The new one doesn't work properly!!

    EDIT: nevermind, i figured out another way!!

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