- Home /
DOTween & how to undo SetBlendableScaleBy tweens that get killed
Hi! I have a transform and its localScale gets modified in two places. By default, it's (1,1,1) (let's just call that "1" for simplicity). I'd like the two places that modify its scale to "play nicely" meaning if one of them wants to increase it by .1f and the other tries to increase it by .2f, it should end up at 1.3f. Then after subtracting .1f and .2f, it should of course end up back at 1f.
DOTween's DoBlendableScaleBy method works nicely, but the complication is that sometimes those tweens can be killed and then I don't know what to reset the scale back to.
If one place in the code did:
Vector3 scaleVector = new Vector3(.1f, .1f, 0f);
transform.DOBlendableScaleBy(scaleVector, 1f)); // Make it a little bigger
Then in order to reset the scale I could just call:
transform.DOBlendableScaleBy(-scaleVector, 1f)); // Reset the size, scaleVector is negative here
But if that first tween gets killed part way through (let's say it's only modified the scale by .07f), how do I then reset the scale? I can't necessarily just set it back to 1 because there's potentially another thing setting the scale too, so I'd just like to undo the scale change caused by that first tween. Is there a way to determine how much that tween actually modified the scale of the transform at the moment it got killed so I can negate it? Is there a way to get that value of .07f (in this example) back out of the tween?
I considered trying to rewind the first tween instead, but I'd prefer to create a new one as I'd like the Eases to be different.
Thank you!
Your answer
Follow this Question
Related Questions
GameObject to follow another GameObject through a spline with a dynamic end waypoint 0 Answers
LeanTween, Problem with slower device when loop create and cancel tween in sequences 0 Answers
How to start a Dotween in between a sequence? 1 Answer
2D animations - same controller for different characters 4 Answers