Timeline for How to fix issues with repeated coroutines for lerping values?
Current License: CC BY-SA 4.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 6, 2020 at 8:11 | comment | added | Nikaas | I have a similar thing, where a class wraps a coroutine and knows if it's still running. Upon calling a new start it can choose to stop the current coroutine, ignore the new start or queue the new one after current one finishes. It helped in so many different situations. | |
Nov 5, 2020 at 20:04 | comment | added | DMGregory♦ |
Another strategy I'll use sometimes is to have the coroutine read straight from the live member variable tracking the state I want to animate - currentXP here - and have it continue moving its local "chase" value until they match. Then, if I change the XP and there's already a coroutine animation running, I don't have to cancel it and start a new one - updating my member variable just moves the goalpost it's moving toward, and it will pick up that change and see it through.
|
|
Nov 5, 2020 at 19:57 | comment | added | MKorialstrasz Krasus | This seems to be exactly what I needed! ^_^ My brainstormed solution was to add an if-check that would branch out the execution of the coroutine into reducing or increasing fill based whether the values were added or subtracted, like in my comment on the first answer :) | |
Nov 5, 2020 at 19:55 | vote | accept | MKorialstrasz Krasus | ||
Nov 5, 2020 at 19:43 | history | answered | DMGregory♦ | CC BY-SA 4.0 |