I am developing an infinite runner using Unity. I have already figured out how to loop a set of backgrounds randomly but I am having problems doing the same for the objects.
So, I have a few objects or obstacles in my prefabs. I want them to generate randomly in the game, not everything at once though.
How do I do that? Can I please get a well-explained piece of code for the purpose?
EDIT : I want the objects to be destroyed as soon as they move out of camera's view (The cam which is following the player).