Background Loop

Hi, I have a small question, I’ve used the search function but no answer could really help me.

I have programmed a 2D Sidescroller, currently I used an huge background Image and the camera is automatically scrolling from left to right as seen in my script below.

What I would like to do know is to use 3 planes as a background (plane 1, 2 and 3)

If the camera moved XX pixels the plane1 should be placed next to plane3 and so on to create an endless loop.

I don’t want to use the skybox because my background image is a wood which can be endlessly played.

Camera Script:

var cameraSpeed : float = 1.0;

function Update () {


Hallo, this is not an answer to your original question but I propably have an other solution for your problem.

I dont know exactly what your game should look like but maybe it is easier to take only one background plane and scroll the texture on it like this.

private var offsetX : float;

function Update () 
    renderer.material.mainTextureOffset = Vector2(offsetX,0);
    offsetX -= 0.2 * Time.deltaTime;

In that case you dont have the problem to change the positions of multiple planes through the whole scene. If it is necessary to scroll the camera, you can make the plane a child of it, so it will move with it and only fake the scrolling with texture. Ah, one thing, if you want to try it that way, make sure the textures wrap mode is on Repeat, otherwise it wont work.

Hope this could help, good luck!