Kaynağa Gözat

死亡后删除锁链

wulifu 1 yıl önce
ebeveyn
işleme
de7d4bef55

+ 8 - 0
ActionTowerDefense/Assets/Scripts/CharacterRope.cs

@@ -41,4 +41,12 @@ public class CharacterRope : MonoBehaviour
             character1.joint.maxDistance = (character1.transform.position - character2.transform.position).magnitude;
         }
     }
+
+    private void FixedUpdate()
+    {
+        if ((!target1 || target1.isDie) || (!target2 || target2.isDie))
+        {
+            gameObject.SetActive(false);
+        }
+    }
 }

+ 9 - 0
ActionTowerDefense/Assets/Scripts/PlayerRope.cs

@@ -1,6 +1,7 @@
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
+using static UnityEngine.GraphicsBuffer;
 
 public class PlayerRope : MonoBehaviour
 {
@@ -24,4 +25,12 @@ public class PlayerRope : MonoBehaviour
         line.SetPosition(0, PlayerController.instance.transform.position + Vector3.up);
         line.SetPosition(1, targetEnemy.transform.position + Vector3.up);
     }
+
+    private void FixedUpdate()
+    {
+        if (!targetEnemy || targetEnemy.isDie)
+        {
+            gameObject.SetActive(false);
+        }
+    }
 }