multipe targets

im trying to learn unity.

i have turrets that use a radius, each time a gameobject enters the radius the turret will turn towards it.unfortunately, when there are multiple target the turret gets confused as to who he should target. how do i make the turret aim at the first, and then when its dead ( or leaves) it focuses on the next available target

im using c#

it is rather simple. Here is a template for you:

bool turret_has_target = false; //global var

//following should be in Update func
if (!turret_has_target) 
  //your script for targeting
  if (/*aim succesfull*/) turret_has_target = true;
  //your aim code
  //in this part check target presence
  if (/*target destoyed or smth else*/) turret_has_target = false;