void OnTriggerExit(Collider other) { VRSimHandInteraction hand = (VRSimHandInteraction)other.GetComponent(typeof(VRSimHandInteraction)); if (hand != null) { hand.didLeaveReleaseArea(this); m_hands.Remove(hand); } }
void OnTriggerEnter(Collider other) { VRSimHandInteraction hand = (VRSimHandInteraction)other.GetComponent(typeof(VRSimHandInteraction)); if (hand != null) { hand.didEnterReleaseArea(this); m_hands.Add(hand); } }
/// <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); }
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); }