// Update is called once per frame void Update() { if (health <= 0f) { try { enemyrespawn.currentunits.Remove(gameObject.GetComponent <EnemyScript>()); } catch (Exception e) { print("I think I just lost my kid..." + e); } DestroyObject(); } try { if (targets[0] != null) { LookTowardsEnemy(targets[0].transform); print("ShootBangPow"); selfshoot.ShootEnemy(targets[0]); } } catch { } if (MoveOrders == null) { System.Random rnd = new System.Random(); destnum = rnd.Next(Command.destinations.Count); if (Command.destinations[destnum].GetComponent <DestInfo>().unitsassigned.Count < Command.destinations[destnum].GetComponent <DestInfo>().WantedUnits) { Command.destinations[destnum].GetComponent <DestInfo>().unitsassigned.Add(GetComponent <EnemyScript>()); MoveOrders = Command.destinations[destnum].transform; nva.SetDestination(new Vector3(MoveOrders.position.x, MoveOrders.position.y, MoveOrders.position.z)); } } }