- Home /
How can I handle dynamic 2D animations?
The new Unity 3D brings us some interesting 2D animator and Sprite handle features. However I need something less static and more dynamic like skeleton animation or something like Smooth Moves asset does.
I'm trying by myself to make it happen, but I'm facing some problems. First is about Sprite position when I need to replace a sprite:
The code below is only for demonstration. I get the texture before and create a new sprite to replace the old one. Because my char will execute a lot of dynamic moves:
armRight.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
The problem is about pivot that is hard to replace a sprite with the correct position.
I'm using iTween to execute the char moves that will take some animation effect at the end.
This code is only for demonstration:
iTween.RotateTo(anchorLeft.gameObject,
iTween.Hash(
"z", 12,
"time", 1,
"onupdate",
"speed", 3,
"myUpdateFunction",
"looptype", iTween.LoopType.pingPong,
"easetype", iTween.EaseType.easeInOutCirc
));
So I'm looking for new tecniques to enhance it and try to make somehow a dynamic animation, replace sprites easily and create moves without any problem. Is this the right way that I'm following? Is it easy to accomplish without extra payable asset like Smooth Moves or something else?
I need tips about that and thanks all so much.