现在的位置: 首页 > 综合 > 正文

mecanim layers的各种问题,边学边更新

2017年09月17日 ⁄ 综合 ⁄ 共 965字 ⁄ 字号 评论关闭

遇到的第一个问题就是layer的weight字段,



按照官方的教材创建了两个动画层,最开始Wave层的Weight字段位0,然后死活从Idle状态切换不到Wave状态,最后试着把Wave状态设置到1才能正常切换,后来从网上找各种关于weight的资料,都只说了除了默认层之外,其他层要设置为1,但那个weight到底是干啥用的,谁也没说清楚。


后来在官网找到了这个说明:

链接:

http://ru.unity3d-docs.com/Documentation/Manual/MecanimPeformanceandOptimization.html

Layers

Most of the time Mecanim is evaluating animations, and the overhead for AnimationLayers and AnimationStateMachines is
kept to the minimum. The cost of adding another layer to the animator, synchronized or not, depends on what animations and blend trees are played by the layer.
When the weight of the layer is zero, the layer update will be
skipped.

上面说如果weight设置为0,那么这层的更新将被跳过,也就相当于没启用。


接着我又把weight的值位置为其他0到1之间的值,发现基本上这个值就是一个百分比,播放你这个动画的百分比,设置为1就完全播放动画,设置为其他值比如0.5就播放对整个的动画的50%。

这是目前为止认识到的这个值哈,欢迎高手指教。

以下是搜这个weight值时看到的其他说明,先记录下来,后面做demo的时候再看看。

Just
a note on this, if you're using any kind of pooling system for your animated characters you will be better off setting the weight in OnEnable instead of Start. It seems that any changes to layer weight are lost if the Animator is disabled.

抱歉!评论已关闭.