Răsfoiți Sursa

修改顿帧函数

SZAND\msx_2 6 luni în urmă
părinte
comite
184752c7d7

+ 8 - 2
ActionTowerDefense/Assets/Scripts/Characters/BeHitTrigger.cs

@@ -34,10 +34,13 @@ public class BeHitTrigger : MonoBehaviour
 
     public void FreezeFrame(int frame)
     {
+        if (!isFreeze)
+        {
+            origRC = owner.rb.constraints;
+        }
         isFreeze = true;
         freezeFrame = frame;
         owner.ani.speed = 0;
-        origRC = owner.rb.constraints;
         owner.rb.constraints = RigidbodyConstraints.FreezeAll;
     }
 
@@ -49,7 +52,10 @@ public class BeHitTrigger : MonoBehaviour
             {
                 isFreeze = false;
                 owner.ani.speed = 1;
-                owner.rb.constraints = origRC;
+                if (owner.rb.constraints == RigidbodyConstraints.FreezeAll)
+                {
+                    owner.rb.constraints = origRC;
+                }
             }
             freezeFrame -= 1;
         }