What I want to do is to randomly create an object from global structure / array list.
Now I can spawn selected object but I can’t do with randomness
Here is my code
Here is my array in a structure
It is in Structure → Unlocked → Rock
How do I pick a random rock every time it creates new object, I mean I want it to random those rocks every time before create it and place it not just random one time and place the same thing over and over
What should I put in the blank code of create object
Hello, thananaza
I made an example with a logic that can help you. For random, you can create a new variable for this. Here is “RandomRocks”:
Create an object group and put all your rocks:
In events you can randomize your variable using the expression “RandomInRange” from 0 to the limit of the number of child variables -1. And to create based in this randomized variable you can use the action “Create an object from its name” and use the group you have created for all your rocks. In “Name of the object to create” you gonna use an expression to pick inside your array the number of your randomized variable.
I hope the explanation is clear.
2 Likes
Thank you Rasterisko for your concept, I tried it and it worked !!
But what if I copy and put all of these variable into an object variable instead of Scene variable
How do I refer to its child number like your picture here
What should it be over the green line?
I can’t do it with RandomInRange(0,VariableChildCount(MyObjectSpawner.Structure.Rocks)-1)
How to count child in an array of an object instead of Scene array?
But anyway, I’m really grateful for your help! 
Look:
I passed all the variables to an Object called “NewSprite”:
I put one instance of this object in scene, because without any instance the events with this variables can’t work:
And I changed all events to pick variables from this object:
Thanks to @MrMen and @Keith_1357 , because what I’ve learned from arrays has mostly been through their comments (and I keep learning). 
3 Likes
Thanks for answering me again
I’m new to gdevelop and game dev but I’ll keep learning too 
1 Like