I have two lists, one with times and another with positions they look like this:
times: 0.02, 0.07, 1.32
positions: (0,0,0),(1,0,2),(2,0,3)
How would you go about moving a gameobject from position to position at the specific times?
I tried doing a foreach loop that calls a IEnumerator which wait the desired seconds, but it isn't working, it seems the IEnumerator never runs:
private void MoveObjects() {
foreach(LogObject moveObject in logObjects) {
TimeStep(moveObject.RecTime, moveObject.GoId, moveObject.Pos, moveObject.Rot);
}
}
IEnumerator TimeStep(float recTime, string goId, Vector3 pos, Vector3 rot) {
yield return new WaitForSeconds(recTime);
GameObject tempObject = GameObject.Find(goId);
tempObject.transform.position = pos;
tempObject.transform.LookAt(rot);
}
↧