コード例 #1
0
ファイル: SceneChanger.cs プロジェクト: ptlive360/test1
        private void Update()
        {
            if (!EnableSceneChanger)
            {
                return;
            }

            var rightHand = VRTK_DeviceFinder.GetControllerRightHand(true);

            controllerIndex = VRTK_DeviceFinder.GetControllerIndex(rightHand);
            if (ForwardPressed() || Input.GetKeyUp(KeyCode.Space))
            {
                var nextSceneIndex = SceneManager.GetActiveScene().buildIndex + 1;
                if (nextSceneIndex >= SceneManager.sceneCountInBuildSettings)
                {
                    nextSceneIndex = 0;
                }
                SceneManager.LoadScene(nextSceneIndex);
            }

            if (BackPressed() || Input.GetKeyUp(KeyCode.Backspace))
            {
                var previousSceneIndex = SceneManager.GetActiveScene().buildIndex - 1;
                if (previousSceneIndex < 0)
                {
                    previousSceneIndex = SceneManager.sceneCountInBuildSettings - 1;
                }
                SceneManager.LoadScene(previousSceneIndex);
            }
        }
コード例 #2
0
 public void Vibrate_pulse(float strength)
 {
     if (grabbingController != null && IsGrabbed())
     {
         VRTK_SharedMethods.TriggerHapticPulse(VRTK_DeviceFinder.GetControllerIndex(grabbingController), strength);
     }
 }
コード例 #3
0
    //When the controller triggers the collider attached to the gate, this function will be invoked.
    public void Teleport(GameObject controller)
    {
        var distance        = Vector3.Distance(transform.position, destination.position);
        var controllerIndex = VRTK_DeviceFinder.GetControllerIndex(controller.gameObject);

        OnDestinationMarkerSet(SetDestinationMarkerEvent(distance, destination, new RaycastHit(), destination.position, controllerIndex));
    }
コード例 #4
0
        public void pull(GameObject Controller, Transform destination)
        {
            var controller      = (Controller.GetComponent <VRTK_ControllerEvents>() ? Controller.GetComponent <VRTK_ControllerEvents>() : Controller.GetComponentInParent <VRTK_ControllerEvents>());
            var distance        = Vector3.Distance(transform.position, destination.position);
            var controllerIndex = VRTK_DeviceFinder.GetControllerIndex(controller.gameObject);

            OnDestinationMarkerSet(SetDestinationMarkerEvent(distance, destination, new RaycastHit(), destination.position, controllerIndex));
        }
コード例 #5
0
    public void StartGrabAnimationFinished()
    {
        Debug.Log("StartGrab animation finished");
        beginStartGrabTween = false;

        givenGrabbedObject.GetComponent <Rigidbody>().isKinematic = false;

        VRTK_SharedMethods.TriggerHapticPulse(VRTK_DeviceFinder.GetControllerIndex(grabbingObject), 0.75f);

        base.StartGrab(grabbingObject, givenGrabbedObject, givenControllerAttachPoint);
    }
コード例 #6
0
        private void PullString()
        {
            currentPull = Mathf.Clamp((Vector3.Distance(holdControl.transform.position, stringControl.transform.position) - pullOffset) * pullMultiplier, 0, maxPullDistance);
            bowAnimation.SetFrame(currentPull);

            if (!currentPull.ToString("F2").Equals(previousPull.ToString("F2")))
            {
                VRTK_SharedMethods.TriggerHapticPulse(VRTK_DeviceFinder.GetControllerIndex(holdControl.gameObject), bowVibration);
                VRTK_SharedMethods.TriggerHapticPulse(VRTK_DeviceFinder.GetControllerIndex(stringControl.gameObject), stringVibration);
            }
            previousPull = currentPull;
        }
コード例 #7
0
 private void OnCollisionEnter(Collision collision)
 {
     if (grabbingController != null && IsGrabbed())
     {
         collisionForce = VRTK_DeviceFinder.GetControllerVelocity(grabbingController).magnitude *impactMagnifier;
         var hapticStrength = collisionForce / maxCollisionForce;
         VRTK_SharedMethods.TriggerHapticPulse(VRTK_DeviceFinder.GetControllerIndex(grabbingController), hapticStrength, 0.5f, 0.01f);
     }
     else
     {
         collisionForce = collision.relativeVelocity.magnitude * impactMagnifier;
     }
 }
コード例 #8
0
        protected override bool CheckRightClicDown()
        {
            bool clicked = false;

#if VRTK_DEFINE_SDK_STEAMVR
            if (VRTK_DeviceFinder.GetControllerRightHand() != null)
            {
                var deviceright = SteamVR_Controller.Input((int)VRTK_DeviceFinder.GetControllerIndex(VRTK_DeviceFinder.GetControllerRightHand()));
                clicked = deviceright.GetPressDown(SteamVR_Controller.ButtonMask.Trigger);
            }
#endif
            return(clicked);
        }
コード例 #9
0
ファイル: RealGun.cs プロジェクト: ptlive360/test1
 public override void StartUsing(GameObject currentUsingObject)
 {
     base.StartUsing(currentUsingObject);
     if (safetySwitch.safetyOff)
     {
         slide.Fire();
         FireBullet();
         VRTK_SharedMethods.TriggerHapticPulse(VRTK_DeviceFinder.GetControllerIndex(controllerEvents.gameObject), 0.63f, 0.2f, 0.01f);
     }
     else
     {
         VRTK_SharedMethods.TriggerHapticPulse(VRTK_DeviceFinder.GetControllerIndex(controllerEvents.gameObject), 0.08f, 0.1f, 0.01f);
     }
 }
コード例 #10
0
 protected override void Update()
 {
     base.Update();
     if (controllerEvents)
     {
         float power = controllerEvents.GetTriggerAxis();
         Spray(power);
         VRTK_SharedMethods.TriggerHapticPulse(VRTK_DeviceFinder.GetControllerIndex(controllerEvents.gameObject), power * 0.25f, 0.1f, 0.01f);
     }
     else
     {
         Spray(0f);
     }
 }
コード例 #11
0
        private void OnTriggerStay(Collider collider)
        {
            var controller = (collider.GetComponent <VRTK_ControllerEvents>() ? collider.GetComponent <VRTK_ControllerEvents>() : collider.GetComponentInParent <VRTK_ControllerEvents>());

            if (controller)
            {
                if (lastUsePressedState == true && !controller.usePressed)
                {
                    var distance        = Vector3.Distance(transform.position, destination.position);
                    var controllerIndex = VRTK_DeviceFinder.GetControllerIndex(controller.gameObject);
                    OnDestinationMarkerSet(SetDestinationMarkerEvent(distance, destination, new RaycastHit(), destination.position, controllerIndex));
                }
                lastUsePressedState = controller.usePressed;
            }
        }
コード例 #12
0
    public GameObject GetControllerByGameObject(GameObject gameObject)
    {
        GameObject obj = null;

        if (gameObject != null)
        {
            int index = -1;
            index = (int)VRTK_DeviceFinder.GetControllerIndex(gameObject);

            if (index > -1)
            {
                obj = VRTK_DeviceFinder.GetControllerByIndex((uint)index, false);
            }
            else
            {
                Debug.LogError("Index is -1");
            }
        }
        else
        {
            Debug.LogError("Trying to get a controller from a go that has a null gameobject");
        }
        return(obj);
    }
コード例 #13
0
 /// <summary>
 /// the function to play a haptic pulse if the player isnt using a vive. (haptics were broken on the vive) TODO: find out which the vive haptics sound wrong.
 /// </summary>
 void TriggerHapticPulse()
 {
     Debug.Log("hapticpulse");
     if (ViveObject == null || ViveObject.GetActive() == false)
     {
         VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetControllerIndex(this.gameObject)), audioahptic);
     }
 }
コード例 #14
0
 public void Released(object o, InteractableObjectEventArgs e)
 {
     sources ["hold"].Stop();
     sources ["throw"].volume = Mathf.Clamp(VRTK_DeviceFinder.GetControllerVelocity(VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetControllerIndex(e.interactingObject))).magnitude / 2, 0, 1);
     sources ["throw"].Play();
 }