If I check to see if the array is empty before I call the method, then I shouldn't need another return statement outside of the foreach loop because the loop will always return a value. How do I fix this?
private bool CanPickupBug()
{
foreach (GameObject bug in bugs)
{
normalDistanceVector = (bug.transform.position - playerCamera.transform.position).normalized;
distanceToBug = Vector3.Distance(bug.transform.position, playerCamera.transform.position);
return (Vector3.Dot(normalDistanceVector, playerCamera.transform.forward) > lookTolerance && distanceToBug < distanceTolerance);
}
}
↧