소스 검색

死亡后删除锁链

wulifu 1 년 전
부모
커밋
de7d4bef55
2개의 변경된 파일17개의 추가작업 그리고 0개의 파일을 삭제
  1. 8 0
      ActionTowerDefense/Assets/Scripts/CharacterRope.cs
  2. 9 0
      ActionTowerDefense/Assets/Scripts/PlayerRope.cs

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