private void GrabByAnchor(IGrabAnchor anchor) { Grabbable grabbed = anchor.Grabbable; _grabbed = grabbed; if (grabbed.GrabbedBySecond == this) { // The first hand to grab will control the object for both hands grabbed.GrabbedBy.SetSecondGrab(anchor, _attacher.Target); } else { // Control the object to follow the hand SetGrab(_grabbed.Body, anchor); } _solidHandMover.Anchor = anchor; _handColliders.SetActive(false); if (_grabbed.GrabPoseID != 0) { SetHandPose(_grabbed.GrabPoseID, true); } // Grab was successful, so we are done OnGrabBegin?.Invoke(grabbed); ClearProximityPose(); }
/// <summary> /// Manually grab an object regardless of its distance from the hand. False is returned if the specified object could not be grabbed. /// </summary> /// <param name="anchor">A GrabAnchor or Grabbable</param> /// <returns></returns> public bool Grab(IGrabAnchor anchor) { // Already grabbing another object? Release it! if (_grabbed != null) { EndGrab(); } #pragma warning disable 618 // Allow use of Internal method ForceGrab if (anchor.TryForceGrab(this, out anchor)) #pragma warning restore 618 { GrabByAnchor(anchor); return(true); } return(false); }
public void SetSecondGrab(IGrabAnchor anchor, Transform target) { _secondAnchor = anchor; _secondTarget = target; }
public void SetGrab(Rigidbody grabbedBody, IGrabAnchor anchor, Hand grabbedBy) { _grabbedBody = grabbedBody; _grabbedAnchor = anchor; _firstGrabbedBy = grabbedBy; }
public bool TryForceGrab(Grabber grabber, out IGrabAnchor anchor) => Grabbable.ForceGrab(this, grabber, out anchor);
private void SetSecondGrab(IGrabAnchor anchor, Transform target) { _attacher.SetSecondGrab(anchor, target); }
private void SetGrab(Rigidbody grabbedBody, IGrabAnchor anchor) { _attacher.SetGrab(grabbedBody, anchor, Controller.Hand); }