DOTween.To and timescale
« on: July 08, 2015, 03:46:10 PM »
Hi there !
First of all I want to thank you for this amazing tool, it's a part of Unity for me ;)
I have some weird issue here. I'm using DOTween.To to shake an object (I know there is a function for that, but that's not the point of the subject), and while the tween is running I set the timeScale to 0. The problem is that the tween will never stop running and calling my function. I'm using an OnUpdate callback to call my function which is shaking my object. I've set the SetUpdate to Late and I let the option to be not timeScaleIndependant.
Here is the line:

Code: [Select]
tweener = DOTween.To(() => this.currentShakeIntensity, (x) => currentShakeIntensity = x, valueObjective, time).SetEase(currentAnimationCurve).SetUpdate(UpdateType.Late).OnUpdate(ShakeObj).OnComplete(StopShaking);
If I set the timeScale at 0 before launching the tween, it won't start, otherwise it won't stop.

Is there anything I can do to fix that? Thanks !

Edit: I made a workaround, I multiply the shake value with Time.timeScale on my callback. It works, but I would assume that the callback should not be called if the TimeScale is set at 0, and called half a time when the TimeScale is set at 0.5.
« Last Edit: July 08, 2015, 03:59:23 PM by cayou »

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: DOTween.To and timescale
« Reply #1 on: July 08, 2015, 06:53:53 PM »
Hi,

First of all, glad you like DOTween :)

About timeScale, the Update callback follows Unity logic, which I believe is the best approach here. Which means that, even if timeScale is 0, Update will still be called but the elapsed time will be 0.

Cheers,
Daniele

Re: DOTween.To and timescale
« Reply #2 on: July 08, 2015, 07:28:29 PM »
Alright, that means my solution is the best one.
Cheers !

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: DOTween.To and timescale
« Reply #3 on: July 08, 2015, 07:55:42 PM »
Absolutely! Your solution rocks! Cheers :)