Move and Repeat Terrain

I have set up a Terrain in the editor with a main camera pointing down the Terrain from the start of it.

I need some how for the Terrain to move towards the camera slowly, but the problem I am facing is to get the Terrain to repat so it looks like it is never ending.

So once the Terrain starts to move towards the camera the same Terrain will have to be created and joined to the end of the first so they keep moving towards the camera seemlesley.

The best way I can think to describe it is kind of like a Tredmill.

You can duplicate the terrain then disconnect the terrain when one goes out of view and move this same terrain down (also out of view) and reconnect.

Create a prefab with the terrain in it and a rigidbody attached. Remove gravity.
Create a cube and set it to a trigger. (1,1,1) Scale is fine.

Position your camera, You will have to tweak this so you don’t see the ground plane spawning.

Move the cube behind your camera. Make sure the cube is level with the ground plane so in my tests both were Y = 0. Mine is at 256,0,-245.

Create an empty object. I placed mine at 0,0,0 my terrain was set to 512 by 512 so I put my camera at 256,5,0. Half way between the terrain.

Create a javascript and attach it to the cube you created and enter this code.

 // Terrain Prefab
 var terrain : GameObject;
 //Spawn Point
 var spawn : GameObject;
 //Speed at which the ground mvoes
 var power : float = 1000;

// calls the spawnTerrain function and spawns a terrain when the game starts
function Start () {

//Crates the terrain from the prefab and applies movement.
function spawnTerrain ()
	var spawn = Instantiate(terrain, spawn.transform.position, spawn.transform.rotation);

// when the terrain collides with the cube a new one is spawned and the current one is destroyed
function OnTriggerEnter (other : Collider)