From a group of 5 objects, I need them to appear one by one on the screen in a different order. For example I have 5 animals: iguana, snake, bear, horse and lizard. If the bear comes out, it must be dragged to the group of mammals, if the frog comes out, to the group of reptiles, etc. At the time of being placed in your group, another animal must appear on the screen to repeat the action until all the animals come out. How could I do that? help me please.
First, rename each animal “animal” plus a number.
So
“animal0”
“animal1”
“animal2”
Etc.
Next add them to an object group of “Animals”
Then you will use the action that is “Create an object by its name”, selecting the object group as the target.
For the name, you would put “animal” + Random(2) (or however many animals you have). Random starts at 0, so by putting Random(2) it could return 0, 1, or 2.
For sorting them, I’d just add some kind of variable named “type” to each animal, and populate it with “Mammals” or “Reptiles”. Then you can use that variable in your event logic.
How do I make it so that the object that has already left the random is not repeated? I only want each object to output once. Help me please @Silver-Streak
I would do 3 things:
- Install the Array Tools extension.
- Set up a scene array, and create a child for every object, then give each child the same number as the index.
- Set up your events similar to this (with whatever conditions/actions/etc you want to trigger this):
The first event gets a random entry in the array and sets its value (one of the numbers) to a variable.
In the second event, the first action creates the object as we mentioned above. The second action then removes the array entry we used to create it. So the next time you call the first event, it can’t ever get that number again.