- Home /
Extract keyframe info from animation clips
I have a 100 frame walk animation for example and I want to extract the elbow position, orientation (global/local whatever works) from the clip at any frame say 24.
Is there any way to do it?
Answer by Paulius-Liekis · Apr 27, 2011 at 08:14 PM
I would simply do something like this:
AnimationState state = animation["walk"]; state.enabled = true; state.weight = 1; state.normalizedTime = 24.0f / 100; animation.Sample();
Transform t = transform.Find("root/pathToElbow/elbow"); Debug.Log("Global position: " + t.position);
Alternative is to read actual curves/keyframes. You can do that only in Editor using AnimationUtility class.
Answer by loopyllama · Apr 27, 2011 at 08:22 PM
Paulius has great suggestions. you can also check out AnimationEvent.time in script
here is a page from the docs describing Animation Events
http://unity3d.com/support/documentation/Components/animeditor-AnimationEvents.html