Пример #1
0
        private IEnumerator Start()
        {
            controller = GetComponent <VRTK_InteractGrab>();
            if (!controller)
            {
                Debug.LogError("The VRTK_InteractGrab script is required to be attached to the controller along with this script.");
                yield break;
            }

            if (!objectToGrab)
            {
                Debug.LogError("You have to assign an object that should be grabbed.");
                yield break;
            }

            while (controller.controllerAttachPoint == null)
            {
                yield return(true);
            }

            VRTK_InteractableObject grabbableObject = objectToGrab;

            if (cloneGrabbedObject)
            {
                grabbableObject = Instantiate(objectToGrab);
            }
            controller.GetComponent <VRTK_InteractTouch>().ForceStopTouching();
            controller.GetComponent <VRTK_InteractTouch>().ForceTouch(grabbableObject.gameObject);
            controller.AttemptGrab();
        }
 public override void Grabbed(VRTK.VRTK_InteractGrab currentGrabbingObject)
 {
     base.Grabbed(currentGrabbingObject);
     Debug.Log("Grabbed");
     controllerEvents = currentGrabbingObject.GetComponent <VRTK.VRTK_ControllerEvents>();
     shootAudio       = GetComponent <AudioSource> ();
 }
Пример #3
0
        private IEnumerator Start()
        {
            controller = GetComponent <VRTK_InteractGrab>();

            if (!controller)
            {
                Debug.LogError("The VRTK_InteractGrab script is required to be attached to the controller along with this script.");
            }

            if (!objectToGrab || !objectToGrab.GetComponent <VRTK_InteractableObject>())
            {
                Debug.LogError("The objectToGrab Game Object must have the VRTK_InteractableObject script applied to it.");
            }

            while (controller.controllerAttachPoint == null)
            {
                yield return(true);
            }

            var grabbableObject = objectToGrab;

            if (cloneGrabbedObject)
            {
                grabbableObject = Instantiate(objectToGrab);
            }
            controller.GetComponent <VRTK_InteractTouch>().ForceTouch(grabbableObject);
            controller.AttemptGrab();
        }
        private IEnumerator AutoGrab()
        {
            controller = GetComponent <VRTK_InteractGrab>();
            if (!controller)
            {
                Debug.LogError("The VRTK_InteractGrab script is required to be attached to the controller along with this script.");
                yield break;
            }

            if (!objectToGrab)
            {
                Debug.LogError("You have to assign an object that should be grabbed.");
                yield break;
            }

            while (controller.controllerAttachPoint == null)
            {
                yield return(true);
            }

            grabbableObject = objectToGrab;
            if (cloneGrabbedObject)
            {
                if (previousClonedObject == null)
                {
                    grabbableObject      = Instantiate(objectToGrab);
                    previousClonedObject = grabbableObject;
                }
                else
                {
                    grabbableObject = previousClonedObject;
                }
            }

            if (grabbableObject.isGrabbable && !grabbableObject.IsGrabbed())
            {
                if (grabbableObject.AttachIsKinematicObject())
                {
                    grabbableObject.ToggleKinematic(true);
                }

                grabbableObject.transform.position = transform.position;
                controller.GetComponent <VRTK_InteractTouch>().ForceStopTouching();
                controller.GetComponent <VRTK_InteractTouch>().ForceTouch(grabbableObject.gameObject);
                controller.AttemptGrab();
            }
        }
        private IEnumerator AutoGrab()
        {
            controller = GetComponent<VRTK_InteractGrab>();
            if (!controller)
            {
                Debug.LogError("The VRTK_InteractGrab script is required to be attached to the controller along with this script.");
                yield break;
            }

            if (!objectToGrab)
            {
                Debug.LogError("You have to assign an object that should be grabbed.");
                yield break;
            }

            while (controller.controllerAttachPoint == null)
            {
                yield return true;
            }

            grabbableObject = objectToGrab;
            if (cloneGrabbedObject)
            {
                if (previousClonedObject == null)
                {
                    grabbableObject = Instantiate(objectToGrab);
                    previousClonedObject = grabbableObject;
                }
                else
                {
                    grabbableObject = previousClonedObject;
                }
            }

            if (grabbableObject.isGrabbable && !grabbableObject.IsGrabbed())
            {
                if (grabbableObject.AttachIsKinematicObject())
                {
                    grabbableObject.ToggleKinematic(true);
                }

                grabbableObject.transform.position = transform.position;
                controller.GetComponent<VRTK_InteractTouch>().ForceStopTouching();
                controller.GetComponent<VRTK_InteractTouch>().ForceTouch(grabbableObject.gameObject);
                controller.AttemptGrab();
            }
        }
Пример #6
0
        private void InitAutoGrab()
        {
            var grabbableObject = objectToGrab;

            if (cloneGrabbedObject)
            {
                grabbableObject = Instantiate(objectToGrab);
            }
            controller.GetComponent <VRTK_InteractTouch>().ForceTouch(grabbableObject);
            controller.AttemptGrab();
        }