private void attack() { //转向 motor.LookRotation(PlayerStatusInfo.instance.headTF.position); //如果不在播放攻击动画时,播放攻击动画 if (!anim.action.isPlaying(anim.attackAnimName)) { anim.action.Play(anim.attackAnimName); } //播放攻击动画 if (atkTime <= Time.time) { //anim.action.Play(anim.attackAnimName); //if(gameObject.name!= "PA_Warrior") Invoke("Shoot", delay); atkTime = Time.time + atkInterval; } }
private void Attack() { motor.LookRotation(PlayerStatusInfo.Instance.transform.position); //限制攻击频率 //播放攻动画 if (atkTime <= Time.time && !gunAnim.IsPlaying(gunAnim.updateAnimName)) { animAction.Play(animAction.atkName); //希望动画播放到某一时刻再执行攻击行为 //建议使用动画事件 Invoke("Shoot", delay); atkTime = Time.time + atkInterval; } if (!animAction.IsPlaying(animAction.atkName) && !gunAnim.IsPlaying(gunAnim.updateAnimName)) { //如果攻击动画没有播放 再 播放闲置动画 animAction.Play(animAction.idleName); } }
void MoveToTarget() { motor.LookRotation(target.transform.position); motor.MoveForward(); }