Awesome asset! I'm having an issue though.

I have this, and it's working fine:

Code: [Select]
transform.DORotate(new Vector3(0, 0, 360), 8, RotateMode.FastBeyond360).SetLoops(-1).SetEase(Ease.Linear);
So I have my sprite spinning counter-clockwise. When I click on it I just want it to spin the opposite direction so I call:

Code: [Select]
transform.DOPlayBackwards();
This plays backwards but only 1 loop and no infinite as it was doing before I told it to play backwards. Is there some backwards loop I'm missing to set infinite?

I just want to have it spin counter-clockwise, then click and play clockwise and alternate on clicks.

Thanks.

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: DOPlayBackwards() Not honoring the amount of loops set before called.
« Reply #1 on: November 15, 2015, 01:39:34 PM »
Hi!

When you play backwards a tween, it will play backwards from its current position, loops included, until it reaches the start of the tween. In short, the tween is treated as if it was a movie timeline, where the loops were part of the timeline itself. This means that, even if you set infinite loops, if you play backwards after 3 loops only 3 loops will elapse before the tween reaches its beginning and stops.

You could use a trick here though. After creating the tween with infinite loops, use Goto (or DOGoto if you're using a target shortcut instead of a tween reference) to send the tween to a time position that is, for example, after 10000 loops. That way, when you play backwards, it will have to go through 10000 loops before it stops.

Cheers,
Daniele
« Last Edit: November 15, 2015, 01:41:09 PM by Daniele »