Counting hits with random value. Random not working here

0 favourites
  • 3 posts
From the Asset Store
An educational game for counting pictures. An easy to use template for developers to build larger games
  • 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?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.)

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




    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)