Ejemplo n.º 1
0
    void OnTriggerExit(Collider other)
    {
        VRSimHandInteraction hand = (VRSimHandInteraction)other.GetComponent(typeof(VRSimHandInteraction));

        if (hand != null)
        {
            hand.didLeaveReleaseArea(this);
            m_hands.Remove(hand);
        }
    }
Ejemplo n.º 2
0
    void OnTriggerEnter(Collider other)
    {
        VRSimHandInteraction hand = (VRSimHandInteraction)other.GetComponent(typeof(VRSimHandInteraction));

        if (hand != null)
        {
            hand.didEnterReleaseArea(this);
            m_hands.Add(hand);
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    ///   Attempts to pickup an object of type VRSimPickupObject
    /// </summary>
    /// <returns>The object.</returns>
    public VRSimPickupObject pickupObject(VRSimHandInteraction hand)
    {
        VRSimPickupObject nearestObject = NearestObjectToHand(hand);

        if (nearestObject)
        {
            nearestObject.Hilight = false;
        }
        return(nearestObject);
    }
Ejemplo n.º 4
0
    protected VRSimPickupObject NearestObjectToHand(VRSimHandInteraction hand)
    {
        Component[] pickupObjects = gameObject.GetComponentsInChildren <VRSimPickupObject>();

        VRSimPickupObject nearest          = null;
        float             nearestMagnitude = float.MaxValue;
        float             pickDistSquared  = PickDistance * PickDistance;

        foreach (VRSimPickupObject obj in pickupObjects)
        {
            float magnitude = (hand.PickupPoint - obj.transform.position).sqrMagnitude;
            if (magnitude < nearestMagnitude && magnitude < pickDistSquared)
            {
                nearest          = obj;
                nearestMagnitude = magnitude;
            }
        }

        return(nearest);
    }