Hi there. I would like some input to help me determine the most efficient way to animate objects in Unity.
I first started using iTween 2.0 which is great and easy to use. but i noticed its slow for my needs. I have been told iTween 3.0 is to be released which addresses these issues.
But I have decided to completely remove the library and do animations manually. Is the Animation View efficient enough to use so that there would be a lag or hiccup when animations are started/stopped? is it the best and fasted solution?
I have been removing instances of itween and replacing them with something like this from within a method.
SomeFunction()
{
...
StartCoroutine(AnimateObject(5.0f));
...
}
IEnumerator AnimateObject(float theDuration)
{
myTransform.localScale = LOCAL_SCALE_MAX;
float elapsedTime = 0.0f;
float elapsedPercent = 0.0f;
float posPercent;
Debug.Log("Begin Animation");
while (true)
{
elapsedTime += Time.deltaTime;
elapsedPercent = elapsedTime/theDuration;
if (elapsedPercent >= 1.0f)
elapsedPercent = 1.0f;
posPercent = LOCAL_SCALE_MAX.x - ((LOCAL_SCALE_MAX.x - LOCAL_SCALE_MIN.x) * elapsedPercent);
myTransform.localScale = new Vector3(posPercent, posPercent, 1.0f);
if (elapsedPercent == 1.0f)
break;
yield return null;
}
Debug.Log("Animation Complete");
}
This works great. Its very fast. Readability is not so good but at this point i dont give a damn. Im going for absolute efficiency in almost every single way.
The problem with this code is that I can only animate objects in a LINEAR manner. I haven’t gotten in to Easing in or Easing out. Can you guys add to this to allow for animation curve.
But then shouldn’t I just use the Animation Window to make curves? Again, is it fast enough?
Thanks