示例#1
0
        private void InitPrimaryGrab(VRTK_InteractableObject currentGrabbedObject)
        {
            if (!currentGrabbedObject.IsValidInteractableController(gameObject, currentGrabbedObject.allowedGrabControllers))
            {
                grabbedObject = null;
                if (currentGrabbedObject.IsGrabbed(gameObject))
                {
                    interactTouch.ForceStopTouching();
                }
                return;
            }

            influencingGrabbedObject = false;
            currentGrabbedObject.SaveCurrentState();
            currentGrabbedObject.Grabbed(gameObject);
            currentGrabbedObject.ZeroVelocity();
            currentGrabbedObject.ToggleHighlight(false);
            currentGrabbedObject.ToggleKinematic(false);

            //Pause collisions (if allowed on object) for a moment whilst sorting out position to prevent clipping issues
            currentGrabbedObject.PauseCollisions();

            if (currentGrabbedObject.grabAttachMechanic == VRTK_InteractableObject.GrabAttachType.Child_Of_Controller)
            {
                currentGrabbedObject.ToggleKinematic(true);
            }
        }
        protected virtual IEnumerator AttemptForceSnapAtEndOfFrame(VRTK_InteractableObject objectToSnap)
        {
            yield return(new WaitForEndOfFrame());

            objectToSnap.SaveCurrentState();
            AttemptForceSnap(objectToSnap.gameObject);
        }
        protected virtual void SetDropSnapType(VRTK_InteractableObject ioCheck)
        {
            switch (snapType)
            {
            case SnapTypes.UseKinematic:
                ioCheck.SaveCurrentState();
                ioCheck.isKinematic = true;
                break;

            case SnapTypes.UseParenting:
                ioCheck.SaveCurrentState();
                ioCheck.isKinematic = true;
                ioCheck.transform.SetParent(transform);
                break;

            case SnapTypes.UseJoint:
                SetSnapDropZoneJoint(ioCheck.GetComponent <Rigidbody>());
                break;
            }
            OnObjectSnappedToDropZone(SetSnapDropZoneEvent(ioCheck.gameObject));
        }
示例#4
0
        // Token: 0x060011F4 RID: 4596 RVA: 0x000679C4 File Offset: 0x00065BC4
        public virtual void ForceSnap(GameObject objectToSnap)
        {
            VRTK_InteractableObject componentInParent = objectToSnap.GetComponentInParent <VRTK_InteractableObject>();

            if (componentInParent != null)
            {
                componentInParent.SaveCurrentState();
                base.StopCoroutine("AttemptForceSnapAtEndOfFrame");
                if (componentInParent.IsGrabbed(null))
                {
                    componentInParent.ForceStopInteracting();
                    base.StartCoroutine(this.AttemptForceSnapAtEndOfFrame(objectToSnap));
                    return;
                }
                this.AttemptForceSnap(objectToSnap);
            }
        }
        protected override void InitPrimaryGrab(VRTK_InteractableObject currentGrabbedObject)
        {
            if (!currentGrabbedObject.IsValidInteractableController(gameObject, currentGrabbedObject.allowedGrabControllers))
            {
                grabbedObject = null;
                if (interactTouch != null && currentGrabbedObject.IsGrabbed(gameObject))
                {
                    interactTouch.ForceStopTouching();
                }
                return;
            }

            influencingGrabbedObject = false;
            currentGrabbedObject.SaveCurrentState();
            currentGrabbedObject.Grabbed(this);
            currentGrabbedObject.ZeroVelocity();
            currentGrabbedObject.isKinematic = false;
        }
        /// <summary>
        /// the ForceSnap method attempts to automatically attach a valid game object to the snap drop zone.
        /// </summary>
        /// <param name="objectToSnap">The GameObject to attempt to snap.</param>
        public virtual void ForceSnap(GameObject objectToSnap)
        {
            VRTK_InteractableObject ioCheck = objectToSnap.GetComponentInParent <VRTK_InteractableObject>();

            if (ioCheck != null)
            {
                ioCheck.SaveCurrentState();
                StopCoroutine("AttemptForceSnapAtEndOfFrame");
                if (ioCheck.IsGrabbed())
                {
                    ioCheck.ForceStopInteracting();
                    StartCoroutine(AttemptForceSnapAtEndOfFrame(objectToSnap));
                }
                else
                {
                    AttemptForceSnap(objectToSnap);
                }
            }
        }
        protected virtual void InitPrimaryGrab(VRTK_InteractableObject currentGrabbedObject)
        {
            GameObject grabbingObject = controllerReference.scriptAlias;

            if (!currentGrabbedObject.IsValidInteractableController(grabbingObject, currentGrabbedObject.allowedGrabControllers))
            {
                grabbedObject = null;
                if (currentGrabbedObject.IsGrabbed(grabbingObject))
                {
                    interactTouch.ForceStopTouching();
                }
                return;
            }

            influencingGrabbedObject = false;
            currentGrabbedObject.SaveCurrentState();
            currentGrabbedObject.Grabbed(grabbingObject);
            currentGrabbedObject.ZeroVelocity();
            currentGrabbedObject.ToggleHighlight(false);
            currentGrabbedObject.isKinematic = false;
        }
示例#8
0
 // Token: 0x0600159E RID: 5534 RVA: 0x00076B4C File Offset: 0x00074D4C
 protected virtual void InitPrimaryGrab(VRTK_InteractableObject currentGrabbedObject)
 {
     if (currentGrabbedObject.GetComponent <PhotonObjectInteract>().isGrabbed)
     {
         return;
     }
     if (!currentGrabbedObject.IsValidInteractableController(base.gameObject, currentGrabbedObject.allowedGrabControllers))
     {
         this.grabbedObject = null;
         if (this.interactTouch != null && currentGrabbedObject.IsGrabbed(base.gameObject))
         {
             this.interactTouch.ForceStopTouching();
         }
         return;
     }
     this.influencingGrabbedObject = false;
     currentGrabbedObject.SaveCurrentState();
     currentGrabbedObject.Grabbed(this);
     currentGrabbedObject.ZeroVelocity();
     currentGrabbedObject.ToggleHighlight(false);
     currentGrabbedObject.isKinematic = false;
 }