Sorry, because I know this has been asked a hundred times before. But I have no idea why this code is giving me this error, because I cant see any path it could take for it to not return a value...
Vector3 roadSnapping (Vector3 point){
//goes through every road in the array, checks if snapping to end point
for (int i = 0; i < controlPoints.GetLength (0); i++) {
if (Vector3.Distance (controlPoints [i, 0], point) < 10) {
return controlPoints [i, 0];
} else {
return point;
}
}
}
The "for" loop is unavoidable, it will always go through this, unless the length is less than 1, however if I put a "return point;" after the loop, I get an error message calling it unreachable code.
thanks for any help u can give :)
↧