using UnityEngine; public class GroundSpawner : MonoBehaviour { public GameObject groundPrefab; public Vector3 nextSpawnPos; void Start() { SpawnGround(); } // instantiating ground public void SpawnGround() { GameObject temp = Instantiate(groundPrefab, nextSpawnPos, Quaternion.identity); nextSpawnPos = temp.transform.GetChild(1).transform.position; } }