Quantcast
Channel: Latest Questions by Ranth
Viewing all articles
Browse latest Browse all 10

Checking if first item in array has been destroyed

$
0
0
Hello and thanks for helping. I am making an RTS in which the players units are selected and then I select enemy units for them to destory. The enemy units get placed in an array called updateEnemyList. Each player unit has a function called Attack() which then sorts the list to put the closest enemy in updateEnemyList[0], and then attacks the first GameObject in the Listarray (which is the closest one). I am running into an issue where one the first enemy in the ListArray is killed, I cannot have the player unit find the next enemy in the list. The enemy is killed through a Destroy(gameObject) script attached as a component to the enemy. I have attempted the following method to get the next closest enemy, though it does not work. Units simply go idle once the first enemy is killed. // Update is called once per frame void Update () { if (updateEnemyList.Count > 0 && updateEnemyList [0] == null) Attack (updateEnemyList); } Does anyone have a better way to determine if updateEnemyList [0] has been destroyed by other scripts? Thanks.

Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>