How do I make the items appear randomly?

0 favourites
  • 3 posts
From the Asset Store
Cartoon Funny Item Interface Sound Pack comes with 426 high-quality sound effects
  • When you get close to an object and press the X key, I want to set the item to come out randomly from that object. What should I do?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Do you mean in random position/direction or that you have a list of items to randomly choose from? There is choose() expression, maybe this will work. I'm imagining you mean something like a loot box but I could be wrong.

  • Create a global variable called "numberofthingschestcouldspawn" that represents the amount of objects the chest has to choose from, then give the chest the player walks to a number instance variable called "Thingtospawn" or something like that. Make the chests set that number to ceil(random(0,numberofthingschestcouldspawn)) every tick, meaning that the chest is constantly changing that instance variable to a random whole number in the ragne you want. Create an event on gamepad x pressed, and create subevents on that event for each possibility of that number (a subevent for chest Thingtospawn = 1, another subevent for chest Thingtospawn = 2, etc. etc.) and in those subevents have the chest spawn a singular item. That's how I would do it.

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