Random Loot, spawning and other??

0 favourites
  • 6 posts
From the Asset Store
Perfect, complete, easy to use to use, out-of-the-box inventory system
  • I feel like I always come back to this question and I've never really come away with a solid answer.

    Is there a simple, full-proof way of creating items at random?

    Kill and enemy, an item is selected from a pool at random for it's loot. Or, you have an item that spawns random enemies..

    I feel like this is a very basic function most games have to create variety but C2 doesn't have a quick behavior for it like everything else.

    Anyone have links to tutorials or know a quick/easy way to do this?

    Thank you,

  • There are much more elegant ways but the easiest I can think of off hand is this:

    On enemy destroyed > set value of powerupvariable to floor(random(100)) (or whatever number you like).

    Then.

    If powerupvariable = 1 > spawn powerup1

    if powerupvariable = 2 > spawn powerup2 etc...

    This way if you have 10 powerups then with the above formula you would have a 10% chance of getting a random powerup.

  • There are much more elegant ways but the easiest I can think of off hand is this:

    On enemy destroyed > set value of powerupvariable to floor(random(100)) (or whatever number you like).

    Then.

    If powerupvariable = 1 > spawn powerup1

    if powerupvariable = 2 > spawn powerup2 etc...

    This way if you have 10 powerups then with the above formula you would have a 10% chance of getting a random powerup.

    THANK YOU!!!!

    This is what I needed!

    I just made a simple mock up with the idea you posted and with a few little changes I got a working model. This is so simple, but so incredibly powerful.

  • Another way you can also just put all the things you want to choose from inside a family then spawn that family it will spawn one of the objects randomly

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Another way you can also just put all the things you want to choose from inside a family then spawn that family it will spawn one of the objects randomly

    Can you elaborate?

    I'm going to test this but I thought that families would spawn as a group and not as a single item one at a time.

  • If you you use the Create Object Action an set it to a family it will create one instance of a single random object you put into the family

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