Generate random values for different instance

0 favourites
  • 7 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • Hi !

    I have an enemy and i want that each of his instance has a random fire rate. And i want that the fire rate has a new value after every shot.

    I don't understand how do to that and with what.

    Can you help me ?

    I am searching since one week now and i did'nt find anything...

  • random(x)

    Generate a random float from 0 to x, not including x. E.g. random(4) can generate 0, 2.5, 3.29293, but not 4. Use floor(random(4)) to generate just the whole numbers 0, 1, 2, 3.

    after shot > set firerate variable to random(max firerate). I assume you can use +300 if you don't want it to start from 0-max but instead something like 300-max. i haven't needed to use this stuff much in C2 yet.

  • you can also

    random(10,20)

    if you want, for example, random a number between 10 and 20 =P

    also. read the manual xD

  • Thanks for your answer.

    But I know how to generate a random value -_-"

    I don't know how to generate it for each instance of the same object.

    I have an enemy with many instance of him and i want that each of them have a different fire rate.

    I can do something like :

    Every random(1,4) seconde -> Create Object Bullet.

    But this will choose a fire rate for ALL of the instance of my enemy and i don't want that. I want to generate one different for each of them.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm not able to look at capx files, so this might be already cleared.

    You effectively answered your question yourself: "I don't know how to generate it for each instance ..."

    That's the key. Just use the system condition "For each" <img src="smileys/smiley1.gif" border="0" align="middle" />

  • It works. Thanks a lot.

    I knew the "For each" condition but not the Timer Behavior.

    <3

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