I have tried for so long and I have got this far to figure this much out can any one help me using the script that I provide
`public class PlatformManager : MonoBehaviour
{
public int startingNumber;
public List levelComponents;
5. // define it as the height on one or more component objects (The actual value you will need to find out)
public float componentBuffer;
public float screenBuffer;
public List platformList;
10. private Vector3 nextPosition;
private Transform player;
void Start()
{
15. nextPosition = new Vector3(0.0f, -componentBuffer, 0.0f);
platformList = new List<Transform>();
for (int i = 0; i < startingNumber; i++)
{
int randComponent = Random.Range(0, levelComponents.Count);
20. GameObject newPlatform = PoolManager.Spawn(levelComponents[randComponent]);
newPlatform.transform.position = nextPosition;
platformList.Add(newPlatform.transform);
nextPosition.y -= componentBuffer;
}
25. }
void Update()
{
if (player == null)
30. {
player = GameObject.Find("Player(Clone)").transform;
}
else
{
35. if (nextPosition.y > player.position.y - screenBuffer)
{
int randComponent = Random.Range(0, levelComponents.Count);
GameObject newPlatform = PoolManager.Spawn(levelComponents[randComponent]);
newPlatform.transform.position = nextPosition;
40. platformList.Add(newPlatform.transform);
nextPosition.y -= componentBuffer;
}
if (platformList[0].position.y > player.position.y + screenBuffer)
45. {
PoolManager.Despawn(platformList[0].gameObject);
platformList.RemoveAt(0);
}
}
50. }
`