// Use this for initialization void Start() { var controllerEvents = GetComponentInParent <VRTK_ControllerEvents>(); var controllerTouch = GetComponentInParent <VRTK_InteractTouch>(); grabber = GetComponentInParent <VRTK_InteractGrab>(); customAttachPoint = transform.Find("CustomAttachPoint"); handVRController = GetComponent <HandVRController>(); // Register events to detect when close enough to grab if (controllerTouch) { controllerTouch.ControllerTouchInteractableObject += DoStartTouch; controllerTouch.ControllerUntouchInteractableObject += DoEndTouch; } if (controllerEvents) { controllerEvents.TriggerTouchStart += new ControllerInteractionEventHandler(DoTriggerTouchStart); controllerEvents.TriggerTouchEnd += new ControllerInteractionEventHandler(DoTriggerTouchEnd); controllerEvents.TriggerAxisChanged += new ControllerInteractionEventHandler(DoTriggerAxisChanged); controllerEvents.GripAxisChanged += new ControllerInteractionEventHandler(DoGripAxisChanged); controllerEvents.TouchpadPressed += new ControllerInteractionEventHandler(DoTouchpadPressed); controllerEvents.TouchpadReleased += new ControllerInteractionEventHandler(DoTouchpadReleased); controllerEvents.ButtonOneTouchStart += new ControllerInteractionEventHandler(DoButtonOneTouchStart); controllerEvents.ButtonOneTouchEnd += new ControllerInteractionEventHandler(DoButtonOneTouchEnd); controllerEvents.ButtonTwoTouchStart += new ControllerInteractionEventHandler(DoButtonTwoTouchStart); controllerEvents.ButtonTwoTouchEnd += new ControllerInteractionEventHandler(DoButtonTwoTouchEnd); controllerEvents.TouchpadAxisChanged += new ControllerInteractionEventHandler(DoTouchpadAxisChanged); } handVRController.fingerSpread = 0f; handVRController.thumbCurl = thumbRest; handVRController.indexCurl = indexRest; handVRController.middleCurl = middleRest; handVRController.ringCurl = ringRest; handVRController.pinkyCurl = pinkyRest; }
void Start() { fingerCollider = gameObject.GetComponent <Collider>(); handVRController = GetComponentInParent <HandVRController>(); }