Hello everyone!
I came here with a big problem that i’m struggling with now. What i want to do is an animation clip created in script, attached it to the object and animate it. The problem is that when i try to add some rotation curves to the animation clip, it doesn’t work properly.
What i want to accomplish: Animate the rotation of the object in the Z axis.
My code:
AnimationClip clip = new AnimationClip();
AnimationCurve xAxis = new AnimationCurve(new Keyframe(0,0),new Keyframe(10,0));
AnimationCurve yAxis = new AnimationCurve(new Keyframe(0,0),new Keyframe(10,0));
AnimationCurve zAxis = new AnimationCurve(new Keyframe(0,0),new Keyframe(10,50));
clip.SetCurve("",typeof(Transform),"localRotation.x",xAxis);
clip.SetCurve("",typeof(Transform),"localRotation.y",yAxis);
clip.SetCurve("",typeof(Transform),"localRotation.z",zAxis);
animation.AddClip(clip,"Testing");
animation.Play("Testing");
Result: The character gets rotated from 0 to 180 at the Z axis. No animation there, just a quick flip.
Any ideas how can i make the rotation animation in the script? I’ve tried also adding the W axis but it doesn’t work…
Any ideas? I would really appreciate any help