Boxcollider is Triggering but not spawning the Background

Dear Members,

what i want to do is, that a BoxCollider detects the Background, and spawns it to the Front so basically the Background will become Infinite. It is working in the case of detecting the Background, but the Collider is only pulling the Background with the Moving Camera, not moving it to the Place, before the Camera reaches. (Which i wanna do, because you shouldnt see the objects jumping around.

The main Camera Follows my Character.
The main Camera has a EmptyObjects, which is a few centimetres behind the camera. the Empty detecs the Background and should Spawn them In front of the Camera with a Script, written in C.

Heres the Script:

using UnityEngine;
using System.Collections;

public class BGLooper : MonoBehaviour {

        int numBGPanels = 5;

        void OnTriggerStay(Collider collider) { // Look at here
Debug.Log("Hit! Obj: "+collider.gameObject.name);


        float withOfBGObject =((BoxCollider)collider).size.x;
       
        Vector3 pos = collider.transform.position;
               
        pos.x += withOfBGObject * numBGPanels ;
       
        collider.transform.position = pos;
       
        }
}

Is the Mistake in my Logical Thoughts? Because theres a Video on youtube, where it is working:

I would apprichiate any help. thanks in advance

  1. What type of collider is on your detection object and what are its dimensions?
  2. What value are you getting for withOfBGObject?
  3. How many units ahead of your camera do you wish to place the BG object?

This information might shed some light on what is going wrong.

William