private void OnTriggerEnter(Collider other) { BKI_PickupableObject bpo = GetValidPickupable(other.gameObject); if (bpo == null) { return; } if (bpo != null && collidedObject == null) { if (!registeredColliders.Contains(bpo)) { registeredColliders.Add(bpo); } } if (registeredColliders.Count > 0) { BKI_FingerCurler.BKI_Curler_Instance.SetHandUpdateBlend(hand, false); } else { BKI_FingerCurler.BKI_Curler_Instance.SetHandUpdateBlend(hand, true); } }
private void OnTriggerExit(Collider other) { if (other.tag == "pickupableObject") { BKI_PickupableObject bpo = GetValidPickupable(other.gameObject); if (bpo == null) { return; } if (registeredColliders.Contains(bpo)) { registeredColliders.Remove(bpo); if (bpo.GetComponent <Valve.VR.InteractionSystem.Interactable>() != null) { bpo.GetComponent <Valve.VR.InteractionSystem.Interactable>().RemoveHighlight(); } } if (bpo.GetPickupable() == pickedUpObject) { ReleaseObject(); } if (registeredColliders.Count > 0) { BKI_FingerCurler.BKI_Curler_Instance.SetHandUpdateBlend(hand, false); } else { BKI_FingerCurler.BKI_Curler_Instance.SetHandUpdateBlend(hand, true); } } }
public void Start() { parentObj = GetValidPickupable(gameObject); if (parentObj == null) { Destroy(this); } }
// Returns current value. public bool IsHandGripping(BKI_Hand hand) { BKI_HandValues vals = (hand == BKI_Hand.left) ? leftHandValues : rightHandValues; BKI_SteamVR_Behaviour_Skeleton skel = (hand == BKI_Hand.left) ? leftHandSkeleton : rightHandSkeleton; bool canDoLoop = skel.IsFingerFrozen(BKI_Finger.thumb) && (skel.IsFingerFrozen(BKI_Finger.index) || skel.IsFingerFrozen(BKI_Finger.middle) || skel.IsFingerFrozen(BKI_Finger.ring) || skel.IsFingerFrozen(BKI_Finger.pinky)); if (canDoLoop) { for (int i = 1; i < 5; i++) { if (!(skel.IsFingerFrozen((BKI_Finger)i) && !(vals.GetFingerValue((BKI_Finger)i) < 0.1f))) { continue; } if ( (colliderManager.GetRegisteredPickupable(hand, BKI_Finger.thumb) != null && (colliderManager.GetRegisteredPickupable(hand, (BKI_Finger)i)) != null) && colliderManager.GetRegisteredPickupable(hand, BKI_Finger.thumb).GetPickupable() == colliderManager.GetRegisteredPickupable(hand, (BKI_Finger)i).GetPickupable()) { if (hand == BKI_Hand.right) { rhGrippedObject = colliderManager.GetRegisteredPickupable(hand, BKI_Finger.thumb); } else { lhGrippedObject = colliderManager.GetRegisteredPickupable(hand, BKI_Finger.thumb); } return(true); } } } else { if (hand == BKI_Hand.right) { rhGrippedObject = null; } else { lhGrippedObject = null; } return(false); } return(false); }
private void ReleaseObject() { if (pickedUpObject != null) { if (pickedUpObject.CanRelease(pickedUpParent)) { pickedUpObject.ReleaseObject(); } pickedUpObject = null; isHoldingObject = false; } if (collidedObject != null) { collidedObject = null; } }
private void Start() { leftHandSkeleton = BKI_FingerCurler.BKI_Curler_Instance.LeftHandSkeleton; rightHandSkeleton = BKI_FingerCurler.BKI_Curler_Instance.RightHandSkeleton; if (leftHandSkeleton == null || rightHandSkeleton == null) { Debug.LogError("Controllers unassigned. Quitting initialisation."); return; } fingerFrozenLeftHand = new bool[5]; fingerFrozenRightHand = new bool[5]; fingerFrozenValueLeftHand = new float[5]; fingerFrozenValueRightHand = new float[5]; SetupFingerTriggers(); SetupPalmColliders(); registeredPickupableRight = new BKI_PickupableObject[5]; registeredPickupableLeft = new BKI_PickupableObject[5]; }
private void OnTriggerStay(Collider other) { BKI_PickupableObject bpo = GetValidPickupable(other.gameObject); if (!isHandGripping && pickedUpObject != null) { ReleaseObject(); } if (bpo != null) { bpo = bpo.GetPickupable(); if (!registeredColliders.Contains(bpo)) { registeredColliders.Add(bpo); } } // Functions as another "TriggerEnter" moment. if (pickedUpObject == null && registeredColliders.Count > 0) { foreach (IBetterPickupable b in registeredColliders) { if (BKI_FingerCurler.BKI_Curler_Instance.IsHandGrippingDown(hand)) { return; } BKI_PickupableObject bp = null; if (b != null) { bp = b.GetPickupable(); } else { continue; } if (bp == null) { continue; } if (BKI_FingerCurler.BKI_Curler_Instance.GetGrippedObject(hand) != null && BKI_FingerCurler.BKI_Curler_Instance.GetGrippedObject(hand).GetPickupable() == bp.GetPickupable()) { pickedUpObject = BKI_FingerCurler.BKI_Curler_Instance.GetGrippedObject(hand); pickedUpObject.PickupObject(pickedUpParent); isHoldingObject = true; break; } } } if (registeredColliders.Count > 0) { BKI_FingerCurler.BKI_Curler_Instance.SetHandUpdateBlend(hand, false); } else { BKI_FingerCurler.BKI_Curler_Instance.SetHandUpdateBlend(hand, true); } }