not all code paths return a value?
this code:
private GameObject PersonToShoot(){
if (enemyListInTower [0].transform == Spawn.furthestEnemy [0].transform) {
return enemyListInTower [0];
} else {
for (int i = 1; i <= enemyListInTower.Count; i++){
if (enemyListInTower[i].transform == Spawn.furthestEnemy[0].transform){
return enemyListInTower[i];
}
}
}
}
gives the error not all code paths return a value. This function is meant to see if an object is both in the area of a tower and the enemy that has traveled the furthest.
Comment
Answer by getyour411 · Sep 24, 2015 at 03:04 AM
The method is setup to return a GameObject, but on the inner loop it only find return if(enemy = something) so you are getting that error because it does not know what to return for the (for int...loop) iterations where that's not true.