/// <summary> /// UnGrabObject /// UnGrab the current grabbed object /// </summary> protected void UnGrabObject() { if (_currentObject == null) { return; } _currentObject.transform.SetParent(null); _currentObject.UnGrab(); _currentObject = null; }
/// <summary> /// GrabObject /// Grab a HandableObject /// </summary> /// <param name="hObj"> Selected object </param> protected void GrabObject(HandableObject hObj) { if (hObj == null) { return; } hObj.transform.SetParent(transform); hObj.transform.localPosition = -(_controller == OVRInput.Controller.RTouch ? hObj.GrabTransform.localPosition : Vector3.Scale(hObj.GrabTransform.localPosition, new Vector3(-1, 1, 1))); hObj.transform.localRotation = Quaternion.identity; // TODO : Grab with the good rotation hObj.Grab(_controller); _currentObject = hObj; }
private void OnCollisionEnter(Collision collision) { GameObject g = ExecuteEvents.GetEventHandler <IGrabbable>(collision.collider.gameObject); if (g) { HandableObject hO = g.GetComponent <HandableObject>(); if (hO && !hO.IsGrabbed) { if (OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, _controller) > TRIGGER_THRESHOLD) { GrabObject(hO); } } } }