I was creating an animation using the scripting API, and I want to change the mass using the following:
public static function getGrowAnimation(go){
var curveX : AnimationCurve = AnimationCurve.Linear(0, go.transform.localScale.x, 5, go.transform.localScale.x*2);
var curveY : AnimationCurve = AnimationCurve.Linear(0, go.transform.localScale.y,5, go.transform.localScale.y*2);
var curveZ : AnimationCurve = AnimationCurve.Linear(0, go.transform.localScale.z, 5, go.transform.localScale.z*2);
var cMassCurve : AnimationCurve = AnimationCurve.Linear(0, go.rigidbody.mass, 5, go.rigidbody.mass*2);
var clip : AnimationClip = new AnimationClip();
clip.SetCurve("", Rigidbody, "mass", cMassCurve);
clip.SetCurve("", Transform, "localScale.x", curveX);
clip.SetCurve("", Transform, "localScale.y", curveY);
clip.SetCurve("", Transform, "localScale.z", curveZ);
return clip;
}
Where “go” is the game object, but the script doesn’t seem to work.
Then, in a script attached to the gameObject in question calls the above method:
var growthAnimation = AnimationClips.getGrowAnimation(gameObject);
animation.addClip(growthAnimation, "growthAnimation");
The transform animations work, my character is able to grow when the animation is called. But the rigidbody mass doesn’t double up.
Any thoughts?