Пример #1
0
    private IEnumerator Detect()
    {
        Collider[] hitColliders = Physics.OverlapSphere(droneTransform.position, range);

        int found = 0;

        yield return(new WaitForSeconds(duration));

        foreach (Collider c in hitColliders)
        {
            if (c.CompareTag(rayTag))
            {
                Item item = c.gameObject.GetComponentInChildren <Item>();

                if (item != null)
                {
                    found++;

                    Coordinate coordinate = CoordinateUtil.GetCoordinate(droneTransform.position, item.transform.position);

                    Debug.Log("found: " + item.name + " at " + coordinate.ToString());

                    OnItemFound?.Invoke(this, item, coordinate);

                    yield return(new WaitForSeconds(durationPerFind));
                }
            }
        }
    }