Endless Running game random generator ?

Hello
i am working on mobile game and it’s endless running game and it’s about trying avoid traps as far as you can … and i have problem about how i can make the terrain generate to become endless ?

Photo from the terrain :

The following would be my approach to making a game like this:

  1. Setting the camera culling distance to however far I want the player to see ahead.

  2. At each level start, I would instantiate a pre-generated level stub (possibly a prefab) that consists of parts.

  3. Grow the stub by adding pieces to the end of the level. My initial approach would be to instantiate a piece at the end when the player steps on a new piece.

The hardest part is probably getting the piece generation logic implemented so that the levels ‘make sense’.

You’ll have to Instantiate() the ground/platforms/terrain/land as the player goes forward.
Depending on the platforms’ size and gameplay nature you can choose to:

  • Instantiate platform prefabs already created but randomly placed, ordered, and repeated. (Take Subway Surfers as an example)
    OR
  • Instantiate smaller platform blocks like in Minecraft, also randomly placed, ordered, and repeated but it would be trickier.

These are the two ways I can think of atm.

You have probably worked this out by now, but in case some one else comes to look at this.

  1. Endless running games like this take a slightly different view of the world, instead of moving the player, move the terrain. What the player sees as moving forward is actually the world moving backward (this avoids issues with floats getting too large).
  2. Once you wrap your head around that you will need to create an empty game object write up a level segment generating script and attach it. line up a enough of these to exceed the players viewing distance.
  3. Now to create the illusion of never ending terrain. In the update method of the level segment generating script have a condition that detects when the player is sufficiently in front of the segment, when this happens it must remake itself into a new random section of track and move itself to the front of the track. This is both effective and efficient.
    (I’m only new to Unity3D so I cant give any specific technical details but I have used this method in other games development environments.)