I'm making an endless runner game and I want a part of my code to wait for some seconds how can I do this? the problem is that it is deleting the terrain when the edge of the beginning of the new terrain hits the bottom of the camera view.
void Start()
{
StartCoroutine(Example());
}
IEnumerator Example()
{
yield return new WaitForSeconds(5);
}
}
here is my code I want the recycle platform function to execute after a few seconds
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlatformManager : MonoBehaviour
{
[SerializeField]
private GameObject[] _platformPrefabs;
[SerializeField]
private int _zedOffset;
// Start is called before the first frame update
void Start()
{
for (int i = 0; i < _platformPrefabs.Length; i++)
{
Instantiate(_platformPrefabs[i], new Vector3(0, 0, i * 4), Quaternion.Euler(0, 90, 0));
_zedOffset += 4;
}
}
// i want this to wait
public void RecyclePlatform(GameObject Platform)
{
Platform.transform.position = new Vector3(0, 0, _zedOffset);
_zedOffset += 4;
}
}
the recyclePlatform function need to wait before it executes