I use LeanTween for tweening and I really love it. What I like the most about it (compared to other tweening engines I used in the past), is that you don’t even have to instantiate tween-objects, you just pass what you want to tween as parameters to the LeanTween-class and everything is working fine. Unfortunately this seems to have a drawback as well. I hoped/expected that LeanTween would do some intelligent pooling in the background, or that it would at least delete tweens that have come to an end.
I’m afraid I have been mistaken, since having a lot of entities doing a move-tween every few seconds, makes me run out of available tweens every time. (Error: “You have run out of available spaces for tweening. To avoid this error increase the number of spaces available for tweening when you initialize the LeanTween class. ex: LeanTween.init(800);”)
Of course I could do as suggested and increase “available spaces” (tween-count, I guess), but that doesn’t look like a good, sustainable solution.
Therefore I’d like to ask you, if there is any way of deleting finished tweens, or of pooling/reusing them, that you know of?
Right now, I myself don’t see any, as I can neither instantiate (and thereby reuse) tween-objects myself, nor do I find any method or parameter that makes LeanTween delete a tween.
I never used lean tween but in my own tweening soultuon I have Static tween methods on different tweening components that will either create the component on the object and tween, or it will use tweening components already on the game objects if present. Its a pretty trivial thing to implemenant if you got source code access.
More or less just out a static method on the class that gets component and only creates a new one if it is null
Thank you! Yes, modifying/extending on the lean-tween classes is an option of course. I just couldn’t believe there is no built-in way to handle this, and my thought was that I must have overlooked something.
There even is an ‘setDestroyOnComplete(bool)’ method, but unfortunately it does not only destroy the tween, but the tweened object as well, which is somewhat more than I asked for.
Hey Reign!
I am glad you are liking LeanTween. LeanTween does effectively destroy any tweens that have finished. It sounds like you must have a bunch of tweens around (over 400), that haven’t finished. Unless you have discovered a bug that is keeping the tweens as being marked as finished…
I know this is a little old but I downloaded the latest scripts and all is working fine. I do have a lot of treest popping in but not all at once. It seems like tweens are not being resused. Any ideas? I bumped up the maxed allowed but still seems like it running out quickly.