public Vector3 GetSteering(Rigidbody target, ICollection <Transform> obstacles, out Vector3 bestHidingSpot) { if (arriving) { bestHidingSpot = currentSpot; } else { float distToClosest = Mathf.Infinity; bestHidingSpot = Vector3.zero; foreach (Transform o in obstacles) { Vector3 hidingSpot = GetHidingPosition(o, target); float dist = Vector3.Distance(hidingSpot, transform.position); if (dist < distToClosest) { distToClosest = dist; bestHidingSpot = hidingSpot; } } currentSpot = bestHidingSpot; } return(steering.Arrive(bestHidingSpot)); }
public Vector3 GetSteering(Rigidbody target, out Vector3 targetLocation) { targetLocation = target.position; return(steering.Arrive(targetLocation)); }