Instantiate prefabs next to each other?

Hello. I have to achieve an endless driving game. I need to learn how I can instantiate ground prefabs and have them randomly generate right next to each other when the player is close to the edge of the current ground prefab so the gameplay is endless.

Input is much appreciated. Thank you.

You’ll want to look Object Pooling in order to efficiently recycle your ground tiles. If you try to instantiate objects constantly it will be inefficient.

A random generation scheme for your tiles could be done in a lot of different ways. Maybe make a list or dictionary of your tile types and pick a random element to choose which tile to place?