- Home /
Modify individual animation curve
Guys, I'm getting pretty desperate here. As you can see in the image I have an animation of a human model. I need to modify, from script, the value of the Rotation.y in the legRb Animation Clip. Please tell me how is it possible to do so (Basically I need to modify the curve). Thanks.
Answer by Bunny83 · Oct 30, 2011 at 01:09 AM
I don't see a human model but i see the animation curves ;) Your screenshot is quite small so i can't see if the animationclip is an imported animation (fbx import) or an AnimationClip created in Unity. The big difference is that imported animations (from blender, 3dsmax, maya) are read-only because they belong to the fbx file which can't be edited in Unity.
I suggest to change the animation in the modelling tool it's created in. You can of course use an editor script to copy / duplicate the animationClip and store it as .anim file so it can be edited in Unity but i'm not sure if that's what you want.
At runtime you can set a curve, but you can't read them. So changing is a bit difficult:
http://unity3d.com/support/documentation/ScriptReference/AnimationClip.SetCurve.html
Here is a bigger image. http://i40.tinypic.com/2ck411.jpg This is an .fbx model which comes with all the animation and stuff. I created a duplicate of the animation and now I can edit the curves. However, I need to be able to change this one curve (Rotation.y) in real time, I mean to have a public variable which holds the values for this curve, but as I understood from what you said earlier, it's impossible?
If you have the curve of interest as a seperate AnimationCurve, AnimationClip.SetCurve should do what you want.
I'm still a bit confused what you mean by "realtime". Do you want to change the curve every frame, because that doesn't make much sense. An AnimationCurve represents a predefined motion / movement / rotation and is automatically evaluated and applied every frame when the animation is running. If you want to override an animated properties via script, just use LateUpdate and change the rotation / localRotation of your transform.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Is there any good method to keep the collider constant while the local scale shrinking or expanding 1 Answer
Can I use Animator.bodyPosition for modifying the colliders during an animation? 1 Answer
Maya animations not playing in Unity 3 correctly 0 Answers
"DrawOrder and AnimationCurves mismatch". Why? When? -1 Answers