Demigiant / dotween

A Unity C# animation engine. HOTween v2
http://dotween.demigiant.com
Other
2.33k stars 348 forks source link

Changing DOTween Path speed in coroutine #540

Closed vvp3 closed 2 years ago

vvp3 commented 2 years ago

ontriggerenter, I would like to have this

        if (_pathMove.duration > 0.15f)
            StartCoroutine(WaitABit());

the problem is that I cannot setup the Couroutine properly in order to have this working gradually: _pathMove.duration -= 0.001f;

it only gets called in the same frame - why ?

What i want to achieve is this: on triggerenter to have a gradually decaying speed and on trigger exit to set a big speed (the later one i did allready). Do i need to manipulate the speed between the current point and the next one as the duration icannot be affected at runtime ?

Demigiant commented 2 years ago

Ahoy!

You can't correctly change the speed of a tween by changing its duration. Instead you should change the tween's internal timeScale, for example: myTween.timeScale = 0.5f; // make it half-speed Consider that you can also tween a tween's timeScale (myTween.DOTimeScale)

vvp3 commented 2 years ago

ill try on the path ty ;)

vvp3 commented 2 years ago

there is no timescale on path

image

Demigiant commented 2 years ago

Ah you need to act on the tween, not the DOTweenPath component. So after you create the path you should get it's tween via the GetTween() method and then you have access to more advanced functions.

On Wed, Dec 15, 2021, 11:32 vvp3 @.***> wrote:

there is no timescale on path

[image: image] https://user-images.githubusercontent.com/40170139/146170441-e80018ea-57bb-4b21-9d70-45adc3ef1272.png

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/Demigiant/dotween/issues/540#issuecomment-994646164, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB7P6PMZBNUSULNSEZ6SSMLURBVEHANCNFSM5KCBGRBQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.