Skip to content

Instantly share code, notes, and snippets.

@general-games
Created November 11, 2022 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save general-games/75dc9d2146630d9eeea02d5b20e5cbcb to your computer and use it in GitHub Desktop.
Save general-games/75dc9d2146630d9eeea02d5b20e5cbcb to your computer and use it in GitHub Desktop.
Do Sequence Movement
using UnityEngine;
[CreateAssetMenu(menuName = "Gridr/Sequences/DOTween DOSequence Movement")]
public class DoSequenceSequence : MovementSequence
{
public float stepTime;
public override IEnumerator Run(GridEntity entity, Stack<Cell> path, OnSequenceStarted onSequenceStarted, OnSequenceCompleted onSequenceCompleted)
{
Sequence movementSequence = DOTween.Sequence();
float counter = 0f;
while (!path.IsEmpty())
{
Tween movementTween = entity.transform.DOMove(path.Pop().GroundPoint.position + entity.PositionOffset, stepTime).SetEase(Ease.Linear);
movementSequence.Insert(counter += stepTime, movementTween);
}
movementSequence.OnComplete(() => onSequenceCompleted?.Invoke());
yield return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment