5

I have lists of data and I am trying to tween them by sequence. If I put a delay for each of the tween it will not work. What I try to achieve is inserting the delay before the next sequence.

private IEnumerator<float> _CameraTransition()
{
    var camSequence = DOTween.Sequence();

    for (int i = 0; i < CamerasData.Count; i++)
        camSequence.Append(cam.DOFieldOfView(CamerasData[i].fov, CamerasData[i].duration).SetDelay(CamerasData[i].triggerDelay));

    camSequence.Play();
    yield return 0;
}

If I remove the SetDelay it works, but of course no delay

AustinWBryan
  • 3,249
  • 3
  • 24
  • 42
Tengku Fathullah
  • 1,279
  • 1
  • 18
  • 43
  • 2
    While not relevant to your problem: this function, as you've written it, does not need to be a coroutine. Your `yield` instruction is the last statement, meaning that no code is left to execute after the coroutine continues afterwards. – Draco18s no longer trusts SE Jul 20 '18 at 16:18

1 Answers1

17

(NOTE: I'm the developer of the library the OP is talking about)

The correct way to add delays inside a Sequence is to use AppendInterval on the Sequence itself.

for (int i = 0; i < CamerasData.Count; i++) {
   camSequence
      .AppendInterval(CamerasData[i].triggerDelay)
      .Append(cam.DOFieldOfView(CamerasData[i].fov, CamerasData[i].duration));
}

That said, SetDelay should also work in theory, even if it's not recommended. I will add it to my to-check list.

Demigiant
  • 290
  • 2
  • 7