How to build Sequence using While loop? #110
-
Right now, I've a queue with Nodes, and I want the player to move along the selected path nodes which are stored in that queue Right now, my only option is to use while loop and wait for ToYieldInstruction on each Tween and then start the next one as long as there any node in the queue. The side effect of that, there is a minor delay between each tween, I thought maybe its possible to build an entire sequence of the path and then run it in one go, but it seems to me no clear way how to build a sequence in a loop manner while considering the position of the player at the end of each tween.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can use Sequence.Chain() and chail all path positions one after another, like this: var sequence = Sequence.Create();
while (stationPathNodes.Count != 0) {
Vector3 pathNode = stationPathNodes.Dequeue();
sequence.Chain(Tween.Position(transform, pathNode, duration));
}
// wait for the whole Sequence if needed
yield return sequence.ToYieldInstruction(); |
Beta Was this translation helpful? Give feedback.
You can use Sequence.Chain() and chail all path positions one after another, like this: