So I have an array of images that moves with "DoMoveX" and I want them to vibrate, so I move the a little to the right, the doble that to the leff a few times with a loop and then return to the original pos.
The only way I've been able to do it is by doing this("Circulos" means "circles"):
for (int i = 0; i < digitos; i++) { circulos[i].GetComponent<Transform>().DOMoveX(circulos[i].GetComponent<Transform>().position.x + amplitud, .04f).SetId(i).SetEase(Ease.InOutSine).OnComplete(() => { for (i = 0; i < digitos; i++) { circulos[i].GetComponent<Transform>().DOMoveX(circulos[i].GetComponent<Transform>().position.x - amplitud * 2, .04f).SetEase(Ease.InOutSine).SetLoops(5, LoopType.Yoyo).OnComplete(() => { for (int y = 0; y < digitos; y++) circulos[y].GetComponent<Transform>().DOMoveX(circulos[y].GetComponent<Transform>().position.x + amplitud, .04f).SetEase(Ease.InOutSine); }); } }); }
However that create a ton of Tweens, which I think gives problems. The problem is that I can't just call the tween on the same image becuase if I do this it doesn't work:
for (int i = 0; i < digitos; i++) { circulos[i].GetComponent<Transform>().DOMoveX(circulos[i].GetComponent<Transform>().position.x + amplitud, .04f).SetId(i).SetEase(Ease.InOutSine).OnComplete(() => { circulos[i].GetComponent<Transform>().DOMoveX(circulos[i].GetComponent<Transform>().position.x - amplitud * 2, .04f).SetEase(Ease.InOutSine).SetLoops(5, LoopType.Yoyo).OnComplete(() => { for (int y = 0; y < digitos; y++) circulos[y].GetComponent<Transform>().DOMoveX(circulos[y].GetComponent<Transform>().position.x + amplitud, .04f).SetEase(Ease.InOutSine); }); }); }
Any help?
I've think of using sequences or ID but I get confused.Thanks
So I have an array of images that moves with "DoMoveX" and I want them to vibrate, so I move the a little to the right, the doble that to the leff a few times with a loop and then return to the original pos. The only way I've been able to do it is by doing this("Circulos" means "circles"):
for (int i = 0; i < digitos; i++) { circulos[i].GetComponent<Transform>().DOMoveX(circulos[i].GetComponent<Transform>().position.x + amplitud, .04f).SetId(i).SetEase(Ease.InOutSine).OnComplete(() => { for (i = 0; i < digitos; i++) { circulos[i].GetComponent<Transform>().DOMoveX(circulos[i].GetComponent<Transform>().position.x - amplitud * 2, .04f).SetEase(Ease.InOutSine).SetLoops(5, LoopType.Yoyo).OnComplete(() => { for (int y = 0; y < digitos; y++) circulos[y].GetComponent<Transform>().DOMoveX(circulos[y].GetComponent<Transform>().position.x + amplitud, .04f).SetEase(Ease.InOutSine); }); } }); }
However that create a ton of Tweens, which I think gives problems. The problem is that I can't just call the tween on the same image becuase if I do this it doesn't work:
for (int i = 0; i < digitos; i++) { circulos[i].GetComponent<Transform>().DOMoveX(circulos[i].GetComponent<Transform>().position.x + amplitud, .04f).SetId(i).SetEase(Ease.InOutSine).OnComplete(() => { circulos[i].GetComponent<Transform>().DOMoveX(circulos[i].GetComponent<Transform>().position.x - amplitud * 2, .04f).SetEase(Ease.InOutSine).SetLoops(5, LoopType.Yoyo).OnComplete(() => { for (int y = 0; y < digitos; y++) circulos[y].GetComponent<Transform>().DOMoveX(circulos[y].GetComponent<Transform>().position.x + amplitud, .04f).SetEase(Ease.InOutSine); }); }); }
Any help? I've think of using sequences or ID but I get confused.Thanks