浏览代码

修改顿帧函数

SZAND\msx_2 6 月之前
父节点
当前提交
184752c7d7
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      ActionTowerDefense/Assets/Scripts/Characters/BeHitTrigger.cs

+ 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;
         }