How do I spawn loot in random locations inside a sprite

  • Basically I want a bunch of these different loot sprites to spawn in a area defined by a invisible sprite with a different spawn chance for each loot sprite. Like random loot in a room. I want to be able to make different spawn rates for each area, that would be very nice for my game. Is this possible and if not could I still spawn them like that some other way: is there a workaround?

    This is a critical part in my game as looting is a big aspect of it please help me out.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use the random() expression.

    On SpawnCondition - Set RandomVariable to random(100)
    If 0<RandomVariable<30 - Create 30%chanceLootSprite at InvisibleSprite.X+random(-InvisibleSprite.width/2,InvisibleSprite.width/2),InvisibleSprite.Y+random(-InvisibleSprite.Height/2,InvisibleSprite.Height/2)
    If 30<RandomVariable<100 - Create 70%chanceLootSprite at InvisibleSprite.X+random(-InvisibleSprite.width/2,InvisibleSprite.width/2),InvisibleSprite.Y+random(-InvisibleSprite.Height/2,InvisibleSprite.Height/2)[/code:1x62l5ug]
    Repeat for however much loot you want to create.
  • Very helpful thanks!

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