How do I flip the gameobject at every Dotween loop?
Solution 1:
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;
}