- Home /
Why are tweening libraries so horifically slow on iOS and what can we do?
I've been trying to tween a couple of objects in my game to simulate a lobbed ball, basically moving a horizontal and vertical container, both over a set amount of time, with different easing functions.
I've tried iTween - lose 30 fps, just for having 3 tweens on my ipod touch 4g. Same with HOTween - lose 30 fps the second I execute the tweens.
I tried ANi.Mate, but couldn't get it to work, which at least saves me from it's ugly, ugly naming ;)
So.. why is it that this seems to be such a hard thing to do on iOS.
I've now found myself from being quite a way through my game to back to the start, as I need to manually write a whole bunch of easing functions, etc, that work in update methods and do not eat 30fps just to move 3 objects ..
Anyone got any ideas on what I can do? I'm guessing I'm going to have to basically look inside iTween or similar and lift out the easing code.. has anyone got any pointers to any code examples for doing this?
Losing 30 fps for 3 tweens, whatever the tween engine used, is honestly not possible. Probably there's something wrong in the way you create the tweens (or you're animating something that requires additional update time by Unity - like animating a rigidBody with compound colliders - thus the cause is to be found elsewhere). Anyway, you can grab HOTween's easing functions on its Google code source (http://code.google.com/p/hotween/source/browse/#svn%2Ftrunk%2FHoloville%2FHOTween%2FCore%2FEasing)
I agree iTween should not be that expensive. I am using it a lot in my iOS apps with very little overhead. Are you sure that iTween is the issue?
As iTween seems to work with a coroutine, I have a feeling you're creating many instances of routines, like in an Update function.
I too have used iTween in iOS and not noticed what you're describing. As @berenger suggests, you may be creating the tween in an Update() or similar.
Answer by dentedpixel · Nov 27, 2012 at 06:16 PM
I too had issues with iTween on iOS. Because I was so frustrated by the perfomance hit, and I really wanted to still use a tweening library. I wrote my own library called LeanTween.
You can download it here: http://u3d.as/content/dented-pixel/lean-tween/31i
To answer your question; I found the biggest problem with iTween is that for every tween it is instantiating and destroying an object (at least from what I could tell looking through the code). Instantiation is quite an expensive operation in Unity on iOS. So my tweening library avoids this, instantiating all the objects at the beginning of the scene and reusing these objects as needed instead of creating new ones.
Your answer