How do I Spawn random items from inventory

0 favourites
  • 7 posts
From the Asset Store
Random Maze Generator with Door & Key System - tutorial capx
  • hi everyone, so i'm trying to spawn random items from what's in my inventory without any duplicates. I'm working with this capx but I will most likely have more slots... like 30. Is this something that can be done? any help would be great! Thanks

    https://www.dropbox.com/s/vl30jbms1ucpf ... .capx?dl=0

  • Hey mikewalton206,

    with 'spawn item from inventory' you mean you want to drop an item from the inventory?

    I made an example (had to made it with C3, so please use it to open the file):

    c3p: https://1drv.ms/u/s!Ap_-qxoGKbDcd_xKj0E4FkdnXVI

    Do not be surprised, I had to make some changes to make it work. If it does not fit into your game concept, please let me know.

  • Hey mikewalton206,

    with 'spawn item from inventory' you mean you want to drop an item from the inventory?

    I made an example (had to made it with C3, so please use it to open the file):

    c3p: https://1drv.ms/u/s!Ap_-qxoGKbDcd_xKj0E4FkdnXVI

    Do not be surprised, I had to make some changes to make it work. If it does not fit into your game concept, please let me know.

    Well yes and no... I want to spawn the actual inventory item onto the game level. Not just drop the item and not have it appear anyplace. I'm using this idea to actually do something else so I just need to be able to spawn the inventory items at random with no duplicates an then I can go from there and place the actual item where I want on the layout so basically like every X seconds I want to spawn at random one of the items from my inventory and place it for example on the middle of the layout.

  • So you want to spawn a copy of one of the items from the inventory?

    And what do you mean by "no duplicates"? Once one item is spawned, it can't be spawned again?

    Here is one way to do this:

    https://imgur.com/a/okN1n

  • So you want to spawn a copy of one of the items from the inventory?

    And what do you mean by "no duplicates"? Once one item is spawned, it can't be spawned again?

    Here is one way to do this:

    https://imgur.com/a/okN1n

    yes and no... I want to basically randomly drop one of the items from my inventory not make a copy onto the layout. lets say I pick up these... 4 blue items, two red items and 1green item. I right click and a red item drops someplace on the layout like the middle of the screen. now there's only 1 red item left. if I right click again... maybe this time a blue item drops and now there's only 3 blue items left. I right click again and this time I get another red item. now there's no more red items left in my inventory so all that I can randomly spawn now is 3 blue and 1 green item. The 2 red items are on the layout now. so basically there has to be something actually in my inventory for this to work so if my character doesn't pick up anything... no items can get randomly dropped.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So basically take a random item from the inventory and drop it on the ground? You shouldn't have used the word "spawn", it usually means creating something new

    Anyway, here is the code:

  • So basically take a random item from the inventory and drop it on the ground? You shouldn't have used the word "spawn", it usually means creating something new

    Anyway, here is the code:

    thanks! I'll test this out

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