예제 #1
0
    public void pickUp()
    {
        float minDistance = float.MaxValue;
        float distance;

        closestItem = null;
        foreach (InteractableItem item in objectsHoveringOver)
        {
            distance = (item.transform.position - transform.position).sqrMagnitude;
            if (distance < minDistance)
            {
                minDistance = distance;
                closestItem = item;
            }
        }
        interactingItem = closestItem;

        if (interactingItem)
        {
            makeVisible(false);

            if (interactingItem.IsInteracting())
            {
                interactingItem.OnExitInteraction(this);
            }
            interactingItem.OnEnterInteraction(this);
        }
    }