public void GrabBegin() { m_grabbed = this.FindClosestObject(); if (!m_grabbed) { return; // If no grabbable objects in range or at the end of our pointer, end quickly } // There's a difference in what'll happen: // If the current object that's being grabbed has no grabber attached to it, we grab it like normal. // However, if the current object is being grabbed already, we do some things: // 1) If we grab at the same exact trigger point, we simply switch the hands, no problem. // 2) if we grab at different trigger points, then we make it so that the hand that's currently grabbing the object will rotate based on the position of our new hand. // For example, if the right hand is grabbing a gun's handle and the left hand tries to grab the gun's barrel, then the right hand won't let go - rather, it will rotate to match the direction to our left hand. // The rotation resistance will be relative to how loosely or strongly the grab value is. If the grab value >= 0.9, then it ain't moving. If the grab value 0.5 <= x < 0.9, then resisteance is little but it'll rotate. If x < 0.5, then it'll rotate without resistance EVRA_Grabbable grabbedParent = m_grabbed.GrabbableRef; if (grabbedParent.currentGrabber == null) { m_grabbed.GrabbableRef.GrabBegin(this, m_grabbed); } else if (grabbedParent.currentGrabber.grabbed == m_grabbed) { m_grabbed.GrabbableRef.GrabBegin(this, m_grabbed); } else { grabbedParent.currentGrabber.AddOtherGrabVolume(this); AddOtherGrabVolume(grabbedParent.currentGrabber); } }
// All we need to do is ensure that, when this triggers the grabber, we can tell it that "You gotta look at THIS guy". public void Init(EVRA_Grabbable parent) { m_GrabbableRef = parent; }