@[Unity Animation]正播,捯播,暂停动画实现方法)
我参照网上资料倒播失败
代码:animation.speed = -1;
出现下面错误
Animator.speed can only be negative when Animator recorder is enabled. Animator.recorderMode != Anim
以下方法可以设置你的播放状态
方法1
animation.speed = 1; //正播
animation.speed = 0; //暂停
animation.StartPlayback(); //进入倒播模式
animation.speed = -1; //倒播
方法二
在Animator中的Parameters添加一个float变量 然后将这个变量赋给需要倒播的动画片段,动画播放速度等于speed乘以float变量,我们只需要改变float变量就可以改变动画播放的状态了,代码如下:
anim.SetFloat("SingSpeed", 1); //正播
anim.SetFloat("SingSpeed", 0); //暂停
anim.SetFloat("SingSpeed", -1); //倒播