Skip to content

Instantly share code, notes, and snippets.

@general-games
Created November 11, 2022 14:43
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/261ca776c0099b41596d75c5ea0952e4 to your computer and use it in GitHub Desktop.
Save general-games/261ca776c0099b41596d75c5ea0952e4 to your computer and use it in GitHub Desktop.
Do Move Sequence
using UnityEngine;
[CreateAssetMenu(menuName = "Gridr/Sequences/DOTween DOMove Movement")]
public class DoMoveSequence : MovementSequence
{
public float stepTime;
public override IEnumerator Run(GridEntity entity, Stack<Cell> path, OnSequenceStarted onSequenceStarted, OnSequenceCompleted onSequenceCompleted)
{
onSequenceStarted?.Invoke();
while (!path.IsEmpty())
{
DoMove();
yield return new WaitForSeconds(stepTime);
}
onSequenceCompleted?.Invoke();
void DoMove() => entity.transform.DOMove(path.Pop().GroundPoint.position + entity.PositionOffset, stepTime);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment