永发信息网

animator下怎么控制指定动画的播放速度

答案:2  悬赏:10  手机版
解决时间 2021-03-03 02:23
animator下怎么控制指定动画的播放速度
最佳答案
animation.speed = 0.5F;
animation.Play("walk");
yield return new WaitForSeconds(animation["walk"]);//等待播放完毕
animation.speed = 1; //调整回原来的速度
animation.Play("Idle");//播放回原来的动画

或者你调整Time.timeScale,缩放时间值,这样也可以达到控制动画速度的目的,但是副作用是其他模型的动画速度也会变成慢动作。大概流程跟上方的一致。

PS:我实验了一下,事实上楼主你这样的方式也是可以的: m_animation["ANI_SWIM"].speed = 0.1f; //ANI_SWIM是模型的动画序列名称
我在Start()里面设置如上,然后SWIM动画会放慢10倍,但是其他动画播放不受影响,可以实现楼主需要的功能。
全部回答
1,如果要改变速度的动画不多,比如就要停止和正常播放两种状态,可以使用blend tree 进行分支处理,一个是速度为0,一个为1的。 2,使用time.timescale.这没有深入研究,发现很多网站都有提及到。 3,使用unityeditorinternal unityeditorinternal.animatorcontroller ac = animator.runtimeanimatorcontroller as unityeditorinternal.animatorcontroller; unityeditorinternal.statemachine sm = ac.getlayer(1).statemachine; for (int i = 0; i < sm.statecount; i++) { unityeditorinternal.state state = sm.getstate(i); state.speed = 2; debug.log(state.uniquename + " " + state.speed); } void setanimspeedwithcliptag(int layer, string tag, float speed) { unityeditorinternal.animatorcontroller ac = animator.runtimeanimatorcontroller as unityeditorinternal.animatorcontroller; unityeditorinternal.statemachine sm = ac.getlayer(layer).statemachine; for (int i = 0; i < sm.statecount; i++) { unityeditorinternal.state state = sm.getstate(i); if (state.tag == tag) //change speed for all clip with the tag specified state.speed = speed; } } void setanimspeedwithclipname(int layer, string name, float speed) { unityeditorinternal.animatorcontroller ac = animator.runtimeanimatorcontroller as unityeditorinternal.animatorcontroller; unityeditorinternal.statemachine sm = ac.getlayer(layer).statemachine; for (int i = 0; i < sm.statecount; i++) { unityeditorinternal.state state = sm.getstate(i); if (state.uniquename == name) //change speed for only the clip name specified state.speed = speed; } } void setanimspeedoflayer(int layer, float speed) { unityeditorinternal.animatorcontroller ac = animator.runtimeanimatorcontroller as unityeditorinternal.animatorcontroller; unityeditorinternal.statemachine sm = ac.getlayer(layer).statemachine; for (int i = 0; i < sm.statecount; i++) { //change speed for all animation state in the layer unityeditorinternal.state state = sm.getstate(i); state.speed = speed; } }
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
静海镇怎么去啊,有知道地址的么
女人练出翘臀是什么样的感受
河南省开封市五一路与五福路交叉口属于哪个区
去哪里找毕业论文案例
一.填写词语不( )一( ) 年过( )( ) 二.用线连
鸣翠花园B区在哪里啊,我有事要去这个地方
韩国的艺人是不是会被逼着去做微调整容
“洗心葴密“是什么意思?
什么子的耳朵听得见
东城区西总布小学北门在哪里啊,我有事要去这
苏州评弹有哪些名作
EDENUS·万仟堂地址有知道的么?有点事想过去
汪曾祺哪一部作品被拍成电影?
五年级下册口算p19答案
尼古丁 含量最少的香烟
推荐资讯
交通银行的信用卡的帐单接收地点怎么改?
【望洋兴叹的近义词】望洋兴叹的近义词两个
深圳到天津的飞机多少钱?拜托各位大神
描写云的古诗文名句有哪些?
人民币加入sdr “入篮”之后影响有多大
【piano小诗】求将中文小诗译成英文(翻译的好
面包上涂沙拉好吃吗
汤姆·加瓦那在福尔摩斯归来中演的是谁
大家的支付宝都是多少信用
人生才三十啊理想却干巴巴 是哪首歌的歌词
广州市海珠区作家协会我想知道这个在什么地方
爱酷宝童装在哪里啊,我有事要去这个地方
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?