Pārlūkot izejas kodu

修复己方刺客虚弱后无法恢复问题

LAPTOP-OM1V99U2\永远de小亡灵 10 mēneši atpakaļ
vecāks
revīzija
d7e2aa5e11
1 mainītis faili ar 12 papildinājumiem un 10 dzēšanām
  1. 12 10
      ActionTowerDefense/Assets/Scripts/Demonic.cs

+ 12 - 10
ActionTowerDefense/Assets/Scripts/Demonic.cs

@@ -47,6 +47,8 @@ public class Demonic : MoveCharacter
 
     [Header("验证功能开关")]
     public bool upFirstAfterWeaknessOrNot;  //虚弱结束后是否先升高
+
+    public bool isBeBlownUp;    //被击飞
     private void Awake()
     {
     }
@@ -524,23 +526,23 @@ public class Demonic : MoveCharacter
                 }
                 break;
             case CharacterState.Weak:
-
                 if (rb.linearVelocity.magnitude > 1)
                 {
-                    if (ani.GetCurrentAnimatorClipInfo(0)[0].clip.name != "hitted")
+                    if (!isBeBlownUp)
                     {
+                        isBeBlownUp = true;
                         ani.Play("hitted", 0, 0);
                         aniCollider.Play("Hurt", 0, 0);
                     }
                     Vector3 vel = rb.linearVelocity;
-                    if (foot.TrigGround && vel.y < 0)
+                    if (foot.TrigGround && vel.y <= 0)
                     {
-                        vel.y = 0;
+                        vel = Vector3.zero;
                     }
                     else
                     {
-                        vel.y += extraFallGravity * Time.deltaTime;
                         vel.x -= vel.x * decelerationRatio * Time.deltaTime;
+                        vel.y += extraFallGravity * Time.deltaTime;
                     }
 
                     //vel.y = vel.y * (1 - decelerationRatio * Time.deltaTime);
@@ -549,6 +551,10 @@ public class Demonic : MoveCharacter
                 }
                 else
                 {
+                    if (isBeBlownUp)
+                    {
+                        isBeBlownUp = false;
+                    }
                     if (weakTime <= -0.1)
                     {
                         if (upFirstAfterWeaknessOrNot)
@@ -570,22 +576,18 @@ public class Demonic : MoveCharacter
                         {
                             ChangeState(CharacterState.Idle);
                         }
-
                         break;
                     }
-                    else 
+                    else
                     {
                         if (ani.GetCurrentAnimatorClipInfo(0)[0].clip.name != "weak")
                         {
                             ani.Play("weak", 0, 0);
                             aniCollider.Play("Weak", 0, 0);
                             rb.linearVelocity = Vector3.zero;
-                            weakTime = totalWeakTime;
                         }
                     }
-                    rb.linearVelocity = new Vector3(velocityAddition, rb.linearVelocity.y,0);
                 }
-
                 break;
             case CharacterState.BaGua:
                 if (adsorbTime < 0.5)