Counting hits with random value. Random not working here

  • I'm counting hits that my object taken from towers. If this number is = 0.6 I do something.

    I have action: Add random(0.3,0.6) to hited(obj. variable)

    And system not gather random values. When I changed for one number "0.6" system counting properly.

    Is "random(0.3,0.6)" is correct value?

  • From the manual:

    "random(a, b)

    Generate a random float between a and b, including a but not including b."

    This means that:

    Random(0.3 , 0.6) can be 0.3 or more than 0.3.

    but it can't be 0.6. It can at most be 0.59999999 (or something like that, I don't know how precisely random operates.)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you want a value that goes from 0.3, to and including 0.6, I recomend this expression instead:

    0.3 + floor(random(31))/100.

    The "Floor" expression rounds of the number downwards;

    30,999->30.

    0,7345->0.

    25,456->25.

    The /100 converts the number into the appropriate potence. (30/100=0.3)

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