i found a script to find the closest enemy and it works fine. but when the enemy is destroyed it doesn't remove the enemy out of the array. can someone help me please? here is the code im using:
var enemies : GameObject[];
function Update()
{
enemies = GameObject.FindGameObjectsWithTag("enemy");
if(enemies.length > 0)
{
target = enemies[0];
var dist = Vector3.Distance(transform.position, enemies[0].transform.position);
for(var i=0;i<enemies.length;i++) {
var tempDist = Vector3.Distance(transform.position, enemies*.transform.position);*
*if(tempDist < dist) {*
_target = enemies*;*_
_*}*_
_*}*_
_*```*_
_*<p>i tried using:</p>*_
_*```*_
<em>_if (enemies *== null)*_</em>
<em>_*{*_</em>
<em>_*enemies.RemoveAt(i);*_</em>
<em>_*}*_</em>
<em>_*```*_</em>
<em>_*<p>but then it says that it isnt a member of unityengine.GameObject[].</p>*_</em>