bool AttemptGrab(Transform handTransform, out GrabbableData grabbableDataBuffer) { _detectionRay = new Ray(_cameraTransform.position, _cameraTransform.forward); int numberOfHits = Physics.RaycastNonAlloc(_detectionRay, _rayHits, _rayMaxLength, _orbDetectionMask); if (numberOfHits > 0) { IGrabbable hitGrabbable = _rayHits[0].transform.GetComponent <IGrabbable>(); if (hitGrabbable == null) { Debug.LogError("AttemptGrab attempted to pick up something that had no IGrabbable component attached", _rayHits[0].transform); } bool pullIsSuccesful = hitGrabbable.RequestPull(handTransform); if (pullIsSuccesful) { grabbableDataBuffer = new GrabbableData(hitGrabbable, _rayHits[0].transform); return(true); } else { grabbableDataBuffer = null; return(false); } } else { grabbableDataBuffer = null; return(false); } }