浏览代码

小猫忍者_远攻击间隔内不原地起跳

1243896040 2 周之前
父节点
当前提交
356dfd7eee
共有 1 个文件被更改,包括 8 次插入5 次删除
  1. 8 5
      ActionTowerDefense/Assets/Scripts/Enemy/Catninja_Far.cs

+ 8 - 5
ActionTowerDefense/Assets/Scripts/Enemy/Catninja_Far.cs

@@ -19,16 +19,19 @@ public class Catninja_Far : Enemy
                 if (foot.TrigGround)
                 {
                     ChangeMoveDir(true);
-                    Debug.Log(moveDir);
-                    ChangeState(CharacterState.Rise);
-                    Vector3 velocity = rb.velocity;
-                    velocity.y = jumpForce;
-                    rb.velocity = velocity;
+                    if(moveDir.x != 0 || pastAttackTime >= attackController.attackInterval)
+                    {
+                        ChangeState(CharacterState.Rise);
+                        Vector3 velocity = rb.velocity;
+                        velocity.y = jumpForce;
+                        rb.velocity = velocity;
+                    }
                 }
                 else
                 {
                     ChangeState(CharacterState.Fall);
                 }
+                pastAttackTime += Time.deltaTime;
                 return;
             case CharacterState.Rise:
                 if(rb.velocity.y <= 0 && isAttack && pastAttackTime >= attackController.attackInterval)