Skip to content

Instantly share code, notes, and snippets.

@general-games
Last active November 15, 2022 12:32
Show Gist options
  • Save general-games/e40ceb8329b3f666f00239ad63463bf1 to your computer and use it in GitHub Desktop.
Save general-games/e40ceb8329b3f666f00239ad63463bf1 to your computer and use it in GitHub Desktop.
[CreateAssetMenu(menuName = "Gridr/Sequences/DOTween DOJump Movement")]
public class DoJumpSequence : MovementSequence
{
public float stepTime;
public override IEnumerator Run(GridEntity entity, Stack<Cell> path, OnSequenceStarted onSequenceStarted, OnSequenceCompleted onSequenceCompleted)
{
onSequenceStarted?.Invoke();
Sequence movementSequence = DOTween.Sequence
float counter = 0f;
while (!path.IsEmpty())
{
Tween movementTween = entity.transform.DOJump(path.Pop().GroundPoint.position + entity.PositionOffset, .5f, 1,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