- Home /
Question by
andoitz · Jan 14, 2015 at 05:21 PM ·
spritesanimationsclipkeyframes
Sprite Code Animation
Someone know how to do sprite animations with pure code??? I really need that for have the same movement in all the chars in my game.
Thats shit is make me have a big headache.
I need to change the sprite at only 3 keyframes, for an animation clip.
I have something like this:
AnimationClip animClip = new AnimationClip();
Keyframe[] ks;
ks = new Keyframe[3];
ks[0] = new Keyframe(0f, 0f);
ks[1] = new Keyframe(1f, 1f);
ks[2] = new Keyframe(2f, 2f);
AnimationCurve _curve = new AnimationCurve(ks);
animClip.SetCurve("TestAnimation2", typeof(SpriteRenderer), "Sprite", _curve);
animClip.wrapMode = WrapMode.Loop;
game_object.AddComponent ("Animation");
game_object.animation.AddClip (animClip, "AnimationCurve7");
game_object.animation.Play("AnimationCurve7");
The problem is that I can only change float values in setCurve, and I want to change sprites...
Thank you so much :)
Comment
Your answer
Follow this Question
Related Questions
Can't Play Animation Clip When More Than One Clip Is Added To Animation 1 Answer
Play a second animation 2 Answers
Unity is removing keyframes even when animation compression is off 0 Answers
What's the best way to line up sprites between animation states when they aren't symmetrical? 1 Answer
Get list of animation clips 1 Answer