private Transform FindBestSpotInCover(Cover cover, ref float minAngle) { Transform[] avaliableSpots = cover.GetCoverSpots(); Transform bestSpot = null; for (int i = 0; i < avaliableSpots.Length; i++) { Vector3 direction = target.position - avaliableSpots[i].position; if (CheckIfSpotIsValid(avaliableSpots[i])) { float angle = Vector3.Angle(avaliableSpots[i].forward, direction); if (angle < minAngle) { minAngle = angle; bestSpot = avaliableSpots[i]; } } } return(bestSpot); }
private Transform FindBestSpotInCover(Cover t_cover, ref float t_minAngle) { Transform[] availableSpots = t_cover.GetCoverSpots(); Transform bestSpot = null; for (int i = 0; i < availableSpots.Length; i++) { Vector2 Direction = m_target.position - availableSpots[i].position; if (checkIfSpotIsValid(availableSpots[i])) { float angle = Vector2.Angle(availableSpots[i].up, Direction); if (angle < t_minAngle) { t_minAngle = angle; bestSpot = availableSpots[i]; } } } return(bestSpot); }