Endless Runner Instantiate Issue...

Hey, I am trying to make an Endless Runner where the player is being chased by something. I am currently working on making the ground instantiate as the player runs through OnTriggerEnter() game objects to trigger the instantiation. I am having issues with this as the ground instantiates the first time into the new placement, but the next time it simply overlaps the first instantiation. I have pictures to help explain this…

Screenshot by Lightshot < – This is on starting the game. There is the Edging on trigger GO and the spawner location.

Screenshot by Lightshot ← This is upon hitting the first Edging GO, the new ground tiling, edging GO and spawner GO are instantiated.

Screenshot by Lightshot < – This is upon hitting the second set of instantiated GOs, they overlap into the same place.

#pragma strict

var onLeft : boolean = true;
var onRight : boolean = true;
var speed : float;

var GameO : Canvas;
            //Lava Linecast
var lava : Transform;
var body : Transform;
var consumed : boolean = false;
            //Instantiation
var edging : Transform;
var spawner : Transform;
var spawned : boolean = false;

var ground : GameObject;

function Start () {
    GameO = GameO.GetComponent(Canvas);
    GameO.enabled = false;
}

function Update () {
    Lava();
   
    if(onLeft) {
        if(Input.GetKeyDown("f")) {
            transform.position.x += speed;
            onLeft = false;
            onRight = true;
        }
    } else if(onRight) {
        if(Input.GetKeyDown("j")) {
            transform.position.x += speed;
            onRight = false;
            onLeft = true;
        }
    }
}

function OnTriggerEnter2D (other : Collider2D) {
    Debug.Log("HI");
    if(other.CompareTag("Spawn")){
        Spawn();
    }
}

function Spawn() {
    Debug.DrawLine(edging.position, spawner.position, Color.green); //Edge Line
    spawned = Physics2D.Linecast (edging.position, spawner.position, 1 <<LayerMask.NameToLayer("Edge"));
    if (spawned) {
        var clone : GameObject;
        clone = Instantiate(ground,spawner.position,spawner.rotation);
    }
}

function Lava() {
    Debug.DrawLine(body.position, lava.position, Color.green); //Lava Line
    consumed = Physics2D.Linecast (body.position, lava.position, 1 << LayerMask.NameToLayer("Lava"));
    if (consumed) {
        GameO.enabled = true;
    }
}

Help would be lovely on this as it feels like it is frying my brain, also if there is any other information I can provide please let me know and I will be sure to do my best.

It is more likely that you get help when the screenshots and especially the code are directly visible in the forum. For the code, don’t forget to use code tags:

Updated with code in the post, I was having some issues when copy pasting, also the pictures, when put inside the post, they came up with broken links, so I don’t know what happened… sorry for this

Did you check whether the platform ends up at the spawner’s position with the correct rotation?

Yes, it is not rotated, it is being put in the same place x20.94 y-2.18 it should be x30 something or just shy

It looks like the wrong spawn transform is used to place the ground.

I fixed this by putting the spawner in an empty game object and then manipulating the object every time OnTiggerEnter() was called

Thanks for your help!