How do I make the platform spawn after the other one

I am making and Endless runner where I want to spawn a platform everytime the player sets a trigger but when I do the platforms spawn all in the same place on top of each other how do i change that, sorry but I can explain it in English very well

	public bool needToGenerate = false;
	public Transform generate;
	// Update is called once per frame
	void Update () {
		if (needToGenerate)
			GeneratePlatform ();
	}

	void GeneratePlatform()
	{
		GameObject obj = ObjectPooler.current.GetPooledObject ();

		if (obj == null)
			return;
		obj.transform.position = generate.transform.position;
		obj.transform.rotation = transform.rotation;
		obj.SetActive (true);
		needToGenerate = false;
	}

the Transform generate here is a gameboject at the edge of the platform

I believe the problem with your code is that you’re generating new platforms at the same location as your old platforms - but not moving them over on the x-axis by some amount corresponding to the old platform’s width. Essentially you’re dropping all your platforms on top of each other!

What you need to do is shove your new platform over a little bit so that it’s not on top of the earlier platform anymore. I’m assuming that you have a BoxCollider2D attached to your platforms (I think I spied something like that in your screenshots).

If this is the case, then try:

public bool needToGenerate = false; // This holds a value that tells you whether you need to make a new platform
     public Transform generate; //This holds the position of the last object that you generated. At the beginning, I'd guess that you dragged and dropped your first platform into here in the editor?
     // Update is called once per frame
     void Update () {
         if (needToGenerate) // If you need to generate a platform
             GeneratePlatform (); // Then run a function that generates a new platform
     }
 
      void GeneratePlatform()
             {
                 GameObject obj = ObjectPooler.current.GetPooledObject (); // Get the object in the pool that you want to place as the next platform in the level, and assign it to the variable 'obj'
         
                 if (obj == null){ // if there's no such object
                     return; // don't do anything
    }
    
    
                   float width = generate.GetComponent<BoxCollider2D>().size.x; //otherwise, get the width of the previous platform's collider
        
        
                 obj.transform.position = generate.position+new Vector3(width,0f,0f); //place your new platform at the previous one's position plus its width (i.e. put it next to the previous platform)
                 obj.transform.rotation = generate.transform.rotation; //rotate it by the same amount as the previous platform (something similar was in your original script so I'm leaving it here in case it does something I'm unaware of)
                 obj.SetActive (true); //Set your new platform to active
                 needToGenerate = false; //Tell the script that you don't need to generate a new platform.
                 generate = obj.transform; //Tell the script that the next platform it makes should be placed next to the one it just built, rather than an earlier one.
             }