I am still trying to figure out GDevelop workflow, but here is what I want to do:
At the beginning of the scene I would like to randomly spawn 4 objects at the time, listed in array, out of 10. And then to delete from that array the ones that were spawned…
So, I would first make 10 objects/sprites, and then make one control object that has array variable that contains 10 children (fields), and their value would be the same name (string) as 10 objects/sprites previously created?
Then at the beginning of the scene I need to make event to Create an object from its name, and as a name to use random number (converted to string) from the total amount of fields in the array from control object?
Is there any command/function that will automatically calculate total number of fields from the selected array?
After spawning objects based on name of fields in array, how can I delete (pop) those used fields, so I can use another action that will spawn four more random objects based on 6 left from same array?
yes, or, to create random 2 (out of 10), and then again 2, and so on, until all 10 are created. But the thing is, with random spawning I want to avoid possibility to have duplicates. In order to do that I can only think of putting all 10 object names in the array and to remove them moment they are spawned.
I just did something similar, not exactly the same, but I have 14 items I can choose to spawn, I want to only spawn one at a time, but once it is collected by the player, not respawn that one. Info is housed in variable array with a structure for each array including 4 children, one being a true/false boolean which was the key to checking. Here is my code of what I did, maybe it helps spawn some ideas to prevent duplicates , because it prevented any duplicates from spawning in my game. BTW, I housed all items as 1 object, but with multiple animations:
This uses an array to store the numbers with the added bonus of refilling the array if all of the numbers are chosen. I added some events to arrange the sprites to make sure it was working.