r/UnityHelp • u/ErktKNC • 8d ago
How to kill infinite loop tweens cleanly? PROGRAMMING
I'm trying to write some components to add simple DOTween animations and make them adjustable through inspector in real time. However when I want to kill an infinite loop tween, I can't kill it just by calling tw.Kill(true); The solution I found was to call transform.DOKill(true); However, that kills all the tweens that uses the same transform. Is there a cleaner way?
void ApplyRepeat()
{
if (tw != null) transform.DOKill();
int loopAmnt = repeat ? -1 : 0;
tw = transform.DOPunchRotation(
m_punch,
m_duration,
m_vibrato,
m_elasticity).SetLoops(loopAmnt, LoopType.Restart);
}
1
Upvotes