transform
.DOPath(path, animDuration, pathType, pathMode, 10).SetLoops(-1, LoopType.Yoyo)
.SetEase(ease);
This is my simple dotween code to follow path. After every yoyo I want my object to flip or change direction towards its next path waypoint. Is there any dotween way of doing this?
CodePudding user response:
DoTween has OnStepComplete().
DOTween:
Sets a callback that will be fired each time the tween completes a single loop cycle (meaning that, if you set your loops to 3, OnStepComplete will be called 3 times, contrary to OnComplete which will be called only once at the very end). More...
void Start()
{
transform
.DOPath(path, animDuration, pathType, pathMode, 10)
.SetLoops(-1, LoopType.Yoyo)
.SetEase(ease).OnStepComplete(FlipScpite);
}
private void FlipScpite()
{
_spriteRenderer.flipX = !_spriteRenderer.flipX;
}
