unity, Additive Animtion注意事项
以下摘自官方文档:(http://docs.unity3d.com/Manual/AnimationScripting.html)
Additive animations allow you to overlay the effects of one animation on top of any others that may be playing. When generating additive animations, Unity will calculate the difference between the first frame in the animation clip and the current frame. Then it will apply this difference on top of all other playing animations.
Tip: When using Additive animations, it is critical that you also play some other non-additive animation on every transform that is also used in the additive animation, otherwise the animations will add on top of the last frame’s result. This is most certainly not what you want.
其中包含三个要点:
1,Additive动画第一帧是参考帧,其余帧与之求差值。也就是说对于Additive动画而言,各帧是什么样并无卵用,有用的是各帧与第一帧的差值。
2,对于一个Transform,只对其播放Additive动画,可能产生非预期行为。正确的做法是在对一个Transform的某个属性P播放Additive动画的时候至少保证此Transform的属性P同时也在播放着某个非Additive动画,即Additive动画需要一个Base动画作为基础。
3,Additive动画的animationLayer值要比相应的Base动画的animationLayer值大。(参考:http://answers.unity3d.com/questions/218370/basic-question-about-additive-animation.html)
补充:
经过试验,如果一个Transform的某属性P没有相应的Base动画,那么在此Additive动画开始播放时用代码强制设置此Transform的属性P第一帧的值也可以避免additive动画出现非预期行为。
参考:
http://forum.unity3d.com/threads/weird-additive-animation-behavior.40250/
http://answers.unity3d.com/questions/218370/basic-question-about-additive-animation.html