简体   繁体   English

统一中的Mecanim动画

[英]Mecanim Animation in Unity

在此处输入图片说明

I am facing a problem while playing a animation which is already playing at the moment. 播放目前已在播放的动画时,我遇到了问题。
eg I am currently working on boxing fighting game in which when I punch twice, first time animation is played but second time, it doesn't restart animation. 例如,我目前正在制作拳击格斗游戏,当我拳两次时,第一次播放动画,但是第二次却不重新启动动画。
I also tried turning off that animation if it is already running, not finding any clue regarding this problem as I'm beginner in mecanim animation. 我还尝试关闭该动画(如果已经运行),因为我是mecanim动画的初学者,所以没有找到有关此问题的任何线索。

Mecanim doesn't allow you to do this directly. Mecanim不允许您直接执行此操作。 A state can only be in one state at a time. 一个状态一次只能处于一种状态 Either at the end and fading out or at the start and fading in, but not both at once. 要么在结尾处逐渐消失,要么在开始处逐渐消失,但不是一次都消失。

You can do a hacky workaround where you make two states with the same animation and alternate between them each time you want to play that animation. 您可以采用一种变通的解决方法,在该状态下,您可以使用同一动画制作两个状态,并在每次播放该动画时在它们之间切换。 It's annoying to set up and makes it take more effort if you need to refactor, but it does work. 设置很烦人,如果需要重构,则需要花费更多的精力,但它确实有效。

My Animancer plugin on the Unity Asset Store has a function specifically for this situation: CrossFadeNew will always fade the animation in from the beginning. 我在Unity Asset Store上的Animancer插件具有专门针对这种情况的功能:CrossFadeNew始终从一开始就淡入动画。 If it's already playing it will automatically create a new state to fade in while the old one fades out. 如果已经在播放,它将自动创建一个新的状态以淡入,而旧状态则淡出。 Feel free to contact me via the support email address listed on the store page and in the user manual if you have any questions about it. 如有任何疑问,请通过商店页面和用户手册中列出的支持电子邮件地址与我联系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM