Exemplo n.º 1
0
        public override void Grabbed(GameObject currentGrabbingObject)
        {
            base.Grabbed(currentGrabbingObject);

            controllerEvents  = currentGrabbingObject.GetComponent <VRTK_ControllerEvents>();
            controllerActions = currentGrabbingObject.GetComponent <VRTK_ControllerActions>();

            ToggleSlide(true);
            ToggleSafetySwitch(true);

            //Limit hands grabbing when picked up
            if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject) == SDK_BaseController.ControllerHand.Left)
            {
                allowedTouchControllers             = AllowedController.Left_Only;
                allowedUseControllers               = AllowedController.Left_Only;
                slide.allowedGrabControllers        = AllowedController.Right_Only;
                safetySwitch.allowedGrabControllers = AllowedController.Right_Only;
            }
            else if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject) == SDK_BaseController.ControllerHand.Right)
            {
                allowedTouchControllers             = AllowedController.Right_Only;
                allowedUseControllers               = AllowedController.Right_Only;
                slide.allowedGrabControllers        = AllowedController.Left_Only;
                safetySwitch.allowedGrabControllers = AllowedController.Left_Only;
            }
        }
Exemplo n.º 2
0
    public override void Grabbed(VRTK_InteractGrab currentGrabbingObject)
    {
        base.Grabbed(currentGrabbingObject);

        controllerEvents = currentGrabbingObject.GetComponent <VRTK_ControllerEvents>();

        if (slide != null)
        {
            ToggleSlide(true);
        }

        //Limit hands grabbing when picked up
        if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject.controllerEvents.gameObject) == SDK_BaseController.ControllerHand.Left)
        {
            allowedTouchControllers = AllowedController.LeftOnly;
            allowedUseControllers   = AllowedController.LeftOnly;
            if (slide != null)
            {
                slide.allowedGrabControllers = AllowedController.RightOnly;
            }
        }
        else if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject.controllerEvents.gameObject) == SDK_BaseController.ControllerHand.Right)
        {
            allowedTouchControllers = AllowedController.RightOnly;
            allowedUseControllers   = AllowedController.RightOnly;
            if (slide != null)
            {
                slide.allowedGrabControllers = AllowedController.LeftOnly;
            }
        }
    }
Exemplo n.º 3
0
    public override void Grabbed(VRTK_InteractGrab currentGrabbingObject)
    {
        base.Grabbed(currentGrabbingObject);

        slideCollider.enabled = true;

        if (ammoTooltipGameObject != null)
        {
            ammoTooltipGameObject.SetActive(true);
        }

        if (ammoTooltip != null)
        {
            ammoTooltip.UpdateText(bulletsLeftInClip + " / " + bulletClipSize);
        }

        controllerEvents = currentGrabbingObject.GetComponent <VRTK_ControllerEvents>();

        ToggleSlide(true);

        slide.reloadAction += Reloaded;

        if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject.controllerEvents.gameObject) == SDK_BaseController.ControllerHand.Left)
        {
            allowedTouchControllers      = AllowedController.LeftOnly;
            allowedUseControllers        = AllowedController.LeftOnly;
            slide.allowedGrabControllers = AllowedController.RightOnly;
        }
        else if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject.controllerEvents.gameObject) == SDK_BaseController.ControllerHand.Right)
        {
            allowedTouchControllers      = AllowedController.RightOnly;
            allowedUseControllers        = AllowedController.RightOnly;
            slide.allowedGrabControllers = AllowedController.LeftOnly;
        }
    }
Exemplo n.º 4
0
        //-------------------------------------------------
        private void FindBow()
        {
            SDK_BaseController.ControllerHand handType = VRTK_DeviceFinder.GetControllerHand(hand);
            GameObject bowGo;

            bowGo = otherHand.GetComponent <VRTK_InteractGrab>().GetGrabbedObject();
            bow   = bowGo.GetComponent <VRTKLongBow>();
            //bow = hand.otherHand.GetComponentInChildren<VRTKLongBow>();
        }
Exemplo n.º 5
0
 private void OnDisable()
 {
     if (VRTK_DeviceFinder.GetControllerHand(gameObject) == SDK_BaseController.ControllerHand.Left)
     {
         _interactGrab.ControllerUngrabInteractableObject -= new ObjectInteractEventHandler(OnLeftGrabHandler);
         _interactGrab.ControllerGrabInteractableObject   -= new ObjectInteractEventHandler(OnLeftReleaseHandler);
     }
     else if (VRTK_DeviceFinder.GetControllerHand(gameObject) == SDK_BaseController.ControllerHand.Right)
     {
         _interactGrab.ControllerUngrabInteractableObject -= new ObjectInteractEventHandler(OnRightGrabHandler);
         _interactGrab.ControllerUngrabInteractableObject -= new ObjectInteractEventHandler(OnRightReleaseHandler);
     }
 }
Exemplo n.º 6
0
        public override void StartUsing(VRTK_InteractUse currentUsingObject)
        {
            base.StartUsing(currentUsingObject);
            SDK_BaseController.ControllerHand actualHand = VRTK_DeviceFinder.GetControllerHand(usingObject.gameObject);
            Debug.Log(actualHand.ToString());

            if (actualHand == (SDK_BaseController.ControllerHand.Left))
            {
                pb.LeftTrigger();
            }
            else if (actualHand == (SDK_BaseController.ControllerHand.Right))
            {
                pb.RightTrigger();
            }
        }
Exemplo n.º 7
0
        public override void Grabbed(VRTK_InteractGrab currentGrabbingObject)
        {
            base.Grabbed(currentGrabbingObject);

            //Limit hands grabbing when picked up
            if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject.controllerEvents.gameObject) ==
                SDK_BaseController.ControllerHand.Left)
            {
                allowedTouchControllers = AllowedController.LeftOnly;
                allowedUseControllers   = AllowedController.LeftOnly;
            }
            else if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject.controllerEvents.gameObject) ==
                     SDK_BaseController.ControllerHand.Right)
            {
                allowedTouchControllers = AllowedController.RightOnly;
                allowedUseControllers   = AllowedController.RightOnly;
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// ArrowHand被抓取处理函数,替代OnAttachedToHand函数
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void VRTKArrowHand_InteractableObjectGrabbed(object sender, InteractableObjectEventArgs e)
 {
     isGrab   = true;
     hand     = e.interactingObject;
     handType = VRTK_DeviceFinder.GetControllerHand(e.interactingObject);
     ///分别指定相应控制器,即左右手
     if (handType == SDK_BaseController.ControllerHand.Left)
     {
         hand      = VRTK_DeviceFinder.GetControllerLeftHand();
         otherHand = VRTK_DeviceFinder.GetControllerRightHand();
     }
     else if (handType == SDK_BaseController.ControllerHand.Right)
     {
         hand      = VRTK_DeviceFinder.GetControllerRightHand();
         otherHand = VRTK_DeviceFinder.GetControllerLeftHand();
     }
     hand.GetComponent <VRTK_ControllerEvents>().TriggerReleased += VRTKArrowHand_TriggerReleased;
     hand.GetComponent <VRTK_ControllerEvents>().TriggerPressed  += VRTKArrowHand_TriggerPressed;
     FindBow();
 }
Exemplo n.º 9
0
        public override void Grabbed(VRTK_InteractGrab currentGrabbingObject)
        {
            base.Grabbed(currentGrabbingObject);

            controllerEvents = currentGrabbingObject.GetComponent <VRTK_ControllerEvents>();

            if (OVRInput.GetActiveController() != OVRInput.Controller.Touchpad)
            {
                //Limit hands grabbing when picked up
                if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject.controllerEvents.gameObject) == SDK_BaseController.ControllerHand.Left)
                {
                    allowedTouchControllers = AllowedController.LeftOnly;
                    allowedUseControllers   = AllowedController.LeftOnly;
                }
                else if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject.controllerEvents.gameObject) == SDK_BaseController.ControllerHand.Right)
                {
                    allowedTouchControllers = AllowedController.RightOnly;
                    allowedUseControllers   = AllowedController.RightOnly;
                }
            }
        }
Exemplo n.º 10
0
    private void ObjectGrabbed(object sender, InteractableObjectEventArgs e)
    {
        if (firstController != null)
        {
            return;
        }

        firstController = e.interactingObject;

        controllerEvents = e.interactingObject.GetComponent <VRTK_ControllerEvents>();

        if (VRTK_DeviceFinder.GetControllerHand(e.interactingObject) == SDK_BaseController.ControllerHand.Left)
        {
            interactableObject.allowedUseControllers = VRTK_InteractableObject.AllowedController.LeftOnly;
        }
        else if (VRTK_DeviceFinder.GetControllerHand(e.interactingObject) == SDK_BaseController.ControllerHand.Right)
        {
            interactableObject.allowedUseControllers = VRTK_InteractableObject.AllowedController.RightOnly;
        }

        controllerEvents.TouchpadPressed += TouchpadPressed;
    }
Exemplo n.º 11
0
 // Token: 0x06001DE0 RID: 7648 RVA: 0x00097E44 File Offset: 0x00096044
 public override void Grabbed(VRTK_InteractGrab currentGrabbingObject)
 {
     base.Grabbed(currentGrabbingObject);
     this.controllerEvents = currentGrabbingObject.GetComponent <VRTK_ControllerEvents>();
     this.ToggleSlide(true);
     this.ToggleSafetySwitch(true);
     if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject.controllerEvents.gameObject) == SDK_BaseController.ControllerHand.Left)
     {
         this.allowedTouchControllers             = VRTK_InteractableObject.AllowedController.LeftOnly;
         this.allowedUseControllers               = VRTK_InteractableObject.AllowedController.LeftOnly;
         this.slide.allowedGrabControllers        = VRTK_InteractableObject.AllowedController.RightOnly;
         this.safetySwitch.allowedGrabControllers = VRTK_InteractableObject.AllowedController.RightOnly;
         return;
     }
     if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject.controllerEvents.gameObject) == SDK_BaseController.ControllerHand.Right)
     {
         this.allowedTouchControllers             = VRTK_InteractableObject.AllowedController.RightOnly;
         this.allowedUseControllers               = VRTK_InteractableObject.AllowedController.RightOnly;
         this.slide.allowedGrabControllers        = VRTK_InteractableObject.AllowedController.LeftOnly;
         this.safetySwitch.allowedGrabControllers = VRTK_InteractableObject.AllowedController.LeftOnly;
     }
 }
Exemplo n.º 12
0
        protected override void SetControllerAttachPoint()
        {
            //If no attach point has been specified then just use the tip of the controller
            if (controllerReference.model != null && originalControllerTongAttachPoint == null)
            {
                //attempt to find the attach point on the controller
                SDK_BaseController.ControllerHand handType = VRTK_DeviceFinder.GetControllerHand(interactTongTouch.gameObject);
                string    elementPath        = VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.AttachPoint, handType);
                Transform defaultAttachPoint = controllerReference.model.transform.Find(elementPath);

                if (defaultAttachPoint != null)
                {
                    controllerAttachPoint = defaultAttachPoint.GetComponent <Rigidbody>();

                    if (controllerAttachPoint == null)
                    {
                        Rigidbody autoGenRB = defaultAttachPoint.gameObject.AddComponent <Rigidbody>();
                        autoGenRB.isKinematic = true;
                        controllerAttachPoint = autoGenRB;
                    }
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 弓被抓取事件处理函数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void VRTKLongBow_InteractableObjectGrabbed(object sender, InteractableObjectEventArgs e)
        {
            bowCollider.enabled = false;
            isGrab = true;
            ///当抓取LongBow时生成ArrowHand
            GameObject arrowHandClone = Instantiate(arrowHandPrefab);

            handType = VRTK_DeviceFinder.GetControllerHand(e.interactingObject);
            ///分别指定相应控制器,即左右手
            if (handType == SDK_BaseController.ControllerHand.Left)
            {
                hand      = VRTK_DeviceFinder.GetControllerLeftHand();
                otherHand = VRTK_DeviceFinder.GetControllerRightHand();
            }
            else if (handType == SDK_BaseController.ControllerHand.Right)
            {
                hand      = VRTK_DeviceFinder.GetControllerRightHand();
                otherHand = VRTK_DeviceFinder.GetControllerLeftHand();
            }
            //另一只手抓取ArrowHand
            otherHand.GetComponent <VRTK_InteractTouch>().ForceTouch(arrowHandClone);
            otherHand.GetComponent <VRTK_InteractGrab>().AttemptGrab();
        }
Exemplo n.º 14
0
        public void GrabRpc(bool grab, ushort viewId)
        {
            GameObject ioObject        = netvrkManager.GetViewById(viewId).gameObject;
            VRTK_InteractableObject io = ioObject.GetComponent <VRTK_InteractableObject>();

            if (grab)
            {
                io.isGrabbable = false;
                SDK_BaseController.ControllerHand hand = VRTK_DeviceFinder.GetControllerHand(io.GetGrabbingObject());
                if (hand == SDK_BaseController.ControllerHand.Left)
                {
                    ioObject.transform.SetParent(networkLeftHand);
                }
                else if (hand == SDK_BaseController.ControllerHand.Right)
                {
                    ioObject.transform.SetParent(networkRightHand);
                }
            }
            else
            {
                io.isGrabbable = true;
                ioObject.transform.SetParent(null);
            }
        }
 private void PlayHapticEvents()
 {
     NullSpace.SDK.SideOfHaptic whichSide = VRTK_DeviceFinder.GetControllerHand(GetGrabbingObject()) == SDK_BaseController.ControllerHand.Left ? NullSpace.SDK.SideOfHaptic.Left : NullSpace.SDK.SideOfHaptic.Right;
     //Debug.Log("Invoking Haptic Event\n" + whichSide.ToString());
     HapticsOnUse.Invoke(whichSide);
 }