private void BeginDistantGrab() { Grabbable distantGrabbable = FindDistantGrabbable(); if (distantGrabbable != null) { ObjectSnappingAddress snapAddress = this.GetComponent <Snapper>()?.SnapForGrabbable(distantGrabbable.gameObject); //TODO reference to snapper? if (snapAddress != null && snapAddress.point.CanBeDistantGrabbed) { _distantGrabAddress = snapAddress; } } }
/// <summary> /// From IGrabNotifier. Called every frame as the user approaches a grabbable while /// performing the grabbing pose. /// Depending on how closed the grab-gesture is, the hand is interpolated more from /// the user-data to the snap-pose data, generating an "approach" animation directly /// controlled by the gesture. /// </summary> /// <param name="grabbable">The object that is intended to be grabbed.</param> /// <param name="amount">How much the user is performing the grabbing pose (normalised)</param> private void GrabAttemp(GameObject grabbable, float amount) { ObjectSnappingAddress address = SnapForGrabbable(grabbable); if (address != null) { _snapData = address; _allignmentFactor = _fingersSnapFactor = amount; } else { _snapData = null; _allignmentFactor = _fingersSnapFactor = 0f; } }
/// <summary> /// From IGrabNotifier, called when the hand starts grabbing and object. /// Finds the best snap point and overrides the hand to it. /// </summary> /// <param name="grabbable">The grabbed object.</param> private void GrabStarted(GameObject grabbable) { ObjectSnappingAddress address = SnapForGrabbable(grabbable); if (address != null) { _snapData = address; _allignmentFactor = _fingersSnapFactor = 1f; this.puppet.LerpGripOffset(_snapData.pose.Pose, _allignmentFactor, _snapData.point.RelativeTo); _trackOffset = this.puppet.TrackedGripOffset; _grabStartTime = Time.timeSinceLevelLoad; _isGrabbing = true; } }
/// <summary> /// From IGrabNotifier, called when the hand releases an object. /// Remove the overrides from the hand so it is controlled directly by the user. /// </summary> /// <param name="grabbable">The released object.</param> private void GrabEnded(GameObject grabbable) { this.puppet.LerpGripOffset(Pose.identity, 0f, this.transform); _snapData = null; _isGrabbing = false; }
private void CancelDistantGrab() { _distantGrabAddress = null; _autoGrabStartTime = null; }