[SerializeField] private GameObject[] sceneObjects;
[SerializeField] private int objectSlideSpeed;
[SerializeField] private int timer;
[SerializeField] private float targetLocation;
// When the scene loads, you dont want update or else the coroutine will be called every frame
void Start()
{
StartCoroutine(SlideLeft());
}
IEnumerator SlideLeft()
{
for (int i = 0; i < sceneObjects.Length; i++)
{
// [Here], on while we check the conidtion and if it is not true we dont step into it
while(sceneObjects[i].transform.position.x > targetLocation)
{
sceneObjects[i].transform.Translate(objectSlideSpeed * Time.deltaTime * Vector3.left);
// Why you need a timer, if your goal is to start a gameobject when the other one arrived,
// at its destination? O.o
// yield return new WaitForSeconds(timer);
yield return null; // After this yield execution will continue on the [Here] Tag
}
StopSlide();
Destroy(sceneObjects[i]);
}
}
Есть некоторые вещи, которые я не понимаю в вашем ожидаемом поведении, но напишите комментарий, если я что-то не так понял.
И причина, по которой это работает, потому что вы назвали ихв обновлении, но вы как будто создали миллион сопрограмм, и сотни тысяч были в приостановленном исполнении.