How do I create objects at random spots inside an object?

  • I'm creating a game that has rooms sort of like a zelda dungeon, and I'd like to make pickups randomly spawn in the room the player is currently in. Each room is surrounded by a plain box called obj_spawnzone:

    (visually represented here in stunning HD)

    What I'd like to have happen is, every 1-10 seconds, a pickup spawns at a random position inside obj_spawnzone. The first part I've got with an "Every round(random(1,10))" event, but how do I spawn the pickups at a random position inside the object? Keep in mind that I don't want pickups to spawn in rooms the player isn't in.

  • If you'll use system--create object instead of 'spawning' the pickups, you can use x/y instead of image point. Which will allow you to put random in the x and y parameters.

    System-Create Object Pickup at

    X: random(obj_spawnzone.bboxleft, ob_spawnzone.bboxright)

    Y: random(obj_spawnzone.bboxtop, ob_spawnzone.bboxbottom)

    add an 'player is in room' to make sure it won't do it other rooms.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Excellent, that works just fine. Thank you!

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