فهرست منبع

修复飞剑死亡掉落转向bug

SZAND\msx_2 2 ماه پیش
والد
کامیت
3703c8cfa6
1فایلهای تغییر یافته به همراه25 افزوده شده و 13 حذف شده
  1. 25 13
      ActionTowerDefense/Assets/Scripts/Characters/Demonic.cs

+ 25 - 13
ActionTowerDefense/Assets/Scripts/Characters/Demonic.cs

@@ -481,24 +481,32 @@ public class Demonic : MoveCharacter
                     ChangeState(CharacterState.Idle);
                     break;
                 }
-                velocity.y += extraFallGravity * Time.deltaTime;
-                if (leftDir.x > 0.3f)
+                if (canFly && isDie)
                 {
-                    velocity.x = moveSpeed;
-                    if (bodyTrans.localScale.x > 0)
-                    {
-                        Turn();
-                    }
+                    velocity.y += extraFallGravity * Time.deltaTime;
+                    rb.velocity = velocity;
                 }
-                else if (leftDir.x < -0.3f)
+                else
                 {
-                    velocity.x = -moveSpeed;
-                    if (bodyTrans.localScale.x < 0)
+                    velocity.y += extraFallGravity * Time.deltaTime;
+                    if (leftDir.x > 0.3f)
+                    {
+                        velocity.x = moveSpeed;
+                        if (bodyTrans.localScale.x > 0)
+                        {
+                            Turn();
+                        }
+                    }
+                    else if (leftDir.x < -0.3f)
                     {
-                        Turn();
+                        velocity.x = -moveSpeed;
+                        if (bodyTrans.localScale.x < 0)
+                        {
+                            Turn();
+                        }
                     }
+                    rb.velocity = velocity;
                 }
-                rb.velocity = velocity;
                 break;
             case CharacterState.Attack:
                 attackController.JudgeTriggerOnOff();
@@ -710,8 +718,12 @@ public class Demonic : MoveCharacter
             case CharacterState.Attack:
                 break;
             case CharacterState.Die:
-                if (canFly && !isDie)
+                if (canFly)
                 {
+                    if (isDie)
+                    {
+                        return;
+                    }
                     rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ;
                     rb.velocity = Vector3.zero;
                     ChangeState(CharacterState.Fall);