okay, so i've seen a few posts on this topic, but they always end with, "oh i figured it out", and no explanation how. i'm trying to get a char to recover from ragdoll. i can copy all the transforms from the ragdoll to the instantiated character, but can't figure out how to lerp to the beginning of an animation. everything i try just makes them snap directly to the animation. i believe i need to use mathf.LerpAngle, but don't know how to sample the transforms for the animation frame i need? thanks in advance for any help.
If you use animation.CrossFade that should ease everything in. Like this: Code (csharp): animation.CrossFade("Idle", 0.3); That will fade in Idle over 0.3 seconds. Increase the number to smooth it, decrease it to fade in faster. Here's a link to the reference page for animation commands: http://unity3d.com/support/documentation/ScriptReference/30_search.html?q=animation
animation.CrossFade was actually the first approach i tried. it snaps directly to the first frame even with a time variable. I believe this is because it tries to blend from the current animation. there is no current animation however, because it was just instantiated and posed. I'm gonna try to use additive mode and manually blend it in, but if anyone has a better solution, i'd love to hear it.
Hi Kritter, I guess you must not had assigned the weight the clip you want fade in. Like this: ------------ using UnityEngine; using System.Collections; public class example : MonoBehaviour { public void Awake() { animation["MyClip"].time = 2.0F; animation["MyClip"].enabled = true; animation["MyClip"].weight = 1.0; //if you don't assign a value,unity takes it as zero so the Sample() function has no effect !! animation.Sample(); animation["MyClip"].enabled = false; } } ------------------ If sample() goes well, it would take the char to the animation state you refer,the you get what you need.