How to make an infinite landscape or the floor like in games like temple run in blender game engine?
i did something similar in a car game. (Infinite road) If you want to you can download the blend and see how i did it. The file of the Track generator is: TrackGenerator.py

The idea behind the concept is, that you create all kind of objects with the same start and ending. So they have seamless connections. Than you add a new random object when the player gets close enough to the end of your path (or in my case the end of the road).
To controll where to add the next part of the track I created an empty. This empty always is at the end of the path. It is also the object where the script is connected to.
Alway when a new track part is added this empty gets an new Position and orientation. To get this information you need an other empty which is parented to each end of a track part. (those parented objects will automaticly  be added to your scene if you add the track Part, you than can acces them by writing: trackpart.children[0]).
you also need to make shure that the origine of the trackPart objects is at the beginning of the trackPart.

here is an overview what the script does:

it chooses any random trackPart

it adds this part at the and of the Track (with the help of the empty)

than it repositions the empty to the new end of the track.(with the help of the children from the trackPart)

and than it will wait until the player is relativly lose to the end of the track. When he is close enough it will repeat the Process.

here is the code :


from bge import logic as l
from random import randint

def main(co):
    trackGenerator = co.owner
    scene = l.getCurrentScene()
    auto = scene.objects["auto"]
    if trackGenerator["trackLenght"] &lt; auto["distanz"] + 40:
        trackNr = randint(0,anzahlanTracks()-1)
        spawnNext(trackNr, trackGenerator)

def spawnNext(type, trackGenerator):
    scene = l.getCurrentScene()
    name = "TrackPart_" + str(type)
    nextTrackPart = scene.objectsInactive[name]
    next = scene.addObject(nextTrackPart, trackGenerator)
    trackGenerator.worldPosition = next.children[0].worldPosition

    print("size ",next["size"],"   trackLenght: ", trackGenerator["trackLenght"])
    trackGenerator["trackLenght"] = trackGenerator["trackLenght"] + next["size"]

def anzahlanTracks():
    scene = l.getCurrentScene()
    name = "TrackPart"
    anzahl = 0
    for o in scene.objectsInactive:
        #TrackPart_
        if o.name[0:10] == "TrackPart_":
            anzahl += 1
    return anzahl




If you need more information to understand just ask.

CarGame with infinite Road