我目前正在开发一个统一的游戏,我需要一个敌人来攻击一些东西,并让那个物体的生命值降低。基本上攻击序列是:-
1)播放攻击动画2)降低生命值3)重复直到死亡
编辑:对不起,应该展示我的代码,如下所示:
// Check if AI is in attack range
if (transform.position == TargetPostion) {
// If the target has more than 0 health
if (TargetHealthScript.health > 0) {
// Play the animation and then decrement health
animation.Play("bite");
TargetHealthScript.decrementHealth(10.0f);
}
}执行此操作的脚本是用C#编写的
目前我已经在一定程度上做到了这一点,但是,健康递减函数一直被重复调用,我需要一种方法来减慢它的速度。我曾尝试将协程与yield语句一起使用,但没有成功。
如果任何人有任何建议,我将不胜感激
谢谢
发布于 2014-04-07 02:44:08
如果您知道动画将花费多长时间,请尝试使用Update函数,并使用Time.deltaTimeenter link description here来计算经过了多少时间。
然后在此基础上降低健康度。
https://stackoverflow.com/questions/22898178
复制相似问题