Help for a school project. Gameobjects sould appear randomly.

TJ 92 2 years ago updated by Finntroll 2 years ago 8

Hello guys,

I'm very new to Unity and Bolt and asked now for some help. I want to create a sorting game to teach people how to sort their waste correctly. It is for a school project.

The player use drag and drop to put the gameoject onto a trashcan. When
it is the right trashcan the play gets 10 points. After that the
gameobjct will be destroyed. This works.

But I have no idea for this.
I have about 35 gameobjects (2D sprites), that has to appear randomly on the screen.

I would be so happy I someome can offer me an solution or give me some tips how to create such a function.
Thank you very much :)


Bolt Version:
Unity Version:
Unity 2019.2.9f1
Scripting Backend:
.NET Version (API Compatibility Level):

Hi Toby,

This is how i would do it:

1.  create a empty gameobject in the scene named "trashholder" and put all your trash gameobjects under it:

2. Create an object variable that reference it so you can use it in your graphs:

3. Then loop through all the children and set their position:

This has the added benefit of that you can add as many objects as you want, and it will still work.

If you are using GUI rect instead of normal worldspace objects then use this instead:

Good luck and let me know if it works.


thank you for your fast answer.
The approach sounds great. I would like to show you what I am building.

This is the current scene. Objects moving on a conveyor belt from left ro right.

They have to appear at random. Not in a row. This makes is harder for the player to sort the objects.

I worked with a list, but I always get the error message "cannot convert from list to unity engine".

Unity has to select all of the animated objects; but this has to be done by chance. Then acivated the animator, that the object will be displayed in the scene.

Object 14 -> Object 6 -> Object 27 -> ....

Not Object 1 -> Object 2 -> Object 3 -> ....

Unitl the player reached the necessary points to finish the level.

When the player hover over a object the animator stops. Via drag and drop the player can put the object onto the trashcan.

When it is right on he gets ten points.

If you still have some adivce I would be very happy. It is not working at the moment :(

Thank you so much.




Ok, i misunderstood what you tried to achieve.

Using the same approach as before:

Put all your trash under one gameobject

Every 5 seconds we pick one gameobject at random, activate it, and then play its animation.

Please post screenshot of your game hierarchy.

Also best way to get help is via discord:


You can write me directly there if you need some quick help.

Hello Finn,

I'm very glad that you are so motivated to help me :)

I hope it is ok the the gameobject named german. But I can translate it when needed.

I built like you told me, but it doesn't worked. Then I changed the event to on button input. Because the game sould start after clicking a button. Nothing.
Than I changed the animation component to animator component. Still not working.

Unity tells me that the Input Button is not setup.

Here some screenshots:

The objects in box (red border) are the one in the scene for current testing. The rest is above but not used at the moment.

Thanky you again for you support :D

Best regards,



Do you have a button setup under Edit -> Project Settings -> Inputs named ButtonSpieleStarte?

Please change it back to Event Start again for troubleshooting purposes, you can fix the button later. Does the code run? Does it activate a gameobject at random?

How does your animation/animator look for the trash? Printscreen please.

Okay. I rebuilt everything. Except the animation component. The 2D sprites seem not to work with an annimation component but with a animator component. Get one error message. Please see screenshot.

His questions were solved and answered via discord.