Random spawn from other spawn

0 favourites
  • 6 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • I would like to generate a explosives package randomly each time the player exploded a stone. I thought of creating a spawn from the sprite with the explosion (fire+smoke animation), but would have to be random, ie, the explosives package only appears in some explosions. Someone would have an idea of how to do this?

  • I�ve an idea and and it worked but I don't know if is the better solution:

    Rock onDestroyed > System > Set randomNun to random(11)

    (sub-event) System > randomNum>=8 > Explosion > Spawn bulletPackage on layer 1(image point 0)

  • That's a good way to to do it. I would recommend for good clean programming to take out the hardcoded random(11) and random>=8 and change those to variables such as explosionChance and explosionChanceRange.

    The put those variables somewhere like a blank sprite off screen where you can store game wide variables or use global variables. Then you always know where to find those values if you want to tweak them in the future.

  • Thanks for the tips, I'm still learning.

  • I created a system but I believe that is not very efficient. What do you think? (notice that I have not changed the variable names, but I'll do it)

    System > Every 1 seconds > System > Set randomNum to random(15)

    *(sub-event) System randomNum <= 7 > System > Create object rock1 on layer1 at (random(80,640), player.Y+650)

    *(sub-event) System randomNum > 7 / System randomNum <=12 > System > Create object rock2 on layer1 at (random(150,550), player.Y+680)

    *(sub-event) System randomNum > 12 > System > Create object rock3 on layer1 at (random(300,480), player.Y+710)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Another doubt:It would be interesting to use a command randomization separately for each object created?(in this case, using system>every sec three times). This way, different objects could have created simultaneously and interchangeably. I would love to hear from you about these two issues. This will help me to learn how to create systems that are more interesting. Thanks.

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