LAPTOP-OM1V99U2\永远de小亡灵 1 year ago
parent
commit
794ffec381
1 changed files with 6 additions and 1 deletions
  1. 6 1
      ActionTowerDefense/Assets/Scripts/Enemy.cs

+ 6 - 1
ActionTowerDefense/Assets/Scripts/Enemy.cs

@@ -141,7 +141,12 @@ public class Enemy : MoveCharacter
                             id = i;
                             id = i;
                         }
                         }
                     }
                     }
-                    if(bodyTrans.position.x > TowerMap.myTowers[id].transform.position.x)
+                    if (id == -1)
+                    {
+                        moveDir = Vector3.right;
+                        break;
+                    }
+                    if (bodyTrans.position.x > TowerMap.myTowers[id].transform.position.x)
                     {
                     {
                         moveDir = Vector3.left;
                         moveDir = Vector3.left;
                     }
                     }