Really simple code here:
obj.animation[animationClip.name].wrapMode = animationWrapMode; obj.animation[animationClip.name].weight = animationWeight; obj.animation[animationClip.name].speed = animationSpeed;
For the inspector on this script I allow for slotting in the object you want animated (obj) the clip you want to play on that object, picking the wrapmode of the animation from a dropdown, and then setting floats for both weight and speed.
The object plays the animation just fine, and the speed and wrap mode options work perfectly. The weight option doesn't seem to have any effect on the playback of the clip at all. I have a character just looking straight to the right, and it seems like if I set the weight on that clip to 0.5 they should only look halfway to the right. But they don't, they still look all the way to the right.
Any thoughts on this?
asked May 08 '12 at 06:52 PM
So is there some way to actually adjust I guess the "intensity" of an animation via script? Basically I want to use this a lot for character facial animations to control how strongly a particular emotion is showing.
answered May 15 '12 at 10:03 PM
The weight affects how it blends with other, currently playing, animations. The docs mention that the last animation in the chain ignores the weights, since the last one just gets everything left over.
To make weight adjust how far you go, play a non-moving idle on layer 0. Then have yours be on layer 1 (or higher.) Now a weight of, say 25% will "leave" 75% for the idle, and Unity will auto-blend the two in that ratio.
answered May 09 '12 at 01:21 AM