How to create/spawn objects / add them to a scene randomly, while keeping behavior?

Hello! I’ve been working on a game where I want objects to randomly spawn within screen bounds (and be saved, its basically like an idle monster collection game. However, I tried a few different things and can’t seem to figure out how to make it run properly. I got them spawn at the click of a button at one point, but didnt work as intended. I’m trying to randomize from a group of objects while keeping randomized movement (like they’re moving around the screen). I’m super new to GDevelop, I’m coming from years of working with Scratch so it’s been a bit of a challenge haha!

i wanted to add i want duplicates of the same object too, for example 2 instances of Object1. Or, if theres a way to assign a random sprite image to cloned object?

I’m from scratch too. The simplest way would be to create a list of all the possible object names. Then use create object from name with a random number for the list. Hope this helps :grinning:

Thank you! And thats awesome youre from scratch!! ^^ Do you mind explaining how this might look with the code? How would I make a “list” and tell the “create object” command to pick from it, do groups not work? Tysm!!

I normally type in some sort of pseudo code, so try to understand this.

  1. Make an variable called “possibleSpawns” that is an Array.
  2. list all the possible spawns. => possibleSpawns[enemy1, enemy2, etc.]. Make sure the names are the same as the objects.
  3. whenever you want to spawn random, run createObjectFromName(possibleSpawns[randomInRange(0, possibleSpawns.length - 1)])