void UpdateLine()
    {
        Vector3[] prediction = new Vector3[32];
        float     tdelta     = Time.fixedDeltaTime;
        float     t          = 0;
        Rigidbody rb         = GetComponent <Rigidbody> ();
        Vector3   velocity   = rb.velocity;

        VRTK.VRTK_ControllerReference controllerReference = VRTK.VRTK_ControllerReference.GetControllerReference(GetGrabbingObject());
        velocity = VRTK.VRTK_DeviceFinder.GetControllerVelocity(controllerReference);
        Vector3 angularVelocity = VRTK.VRTK_DeviceFinder.GetControllerAngularVelocity(controllerReference);

        Vector3 p = transform.position;

        for (int i = 0; i < prediction.Length; ++i)
        {
            p += velocity * tdelta;
            if (rb.useGravity)
            {
                velocity += Physics.gravity * tdelta;
            }
            prediction [i] = p;
        }
        NS.Lines.MakeArrow(ref predictionLine, prediction, prediction.Length, throwLineColor);
    }
Beispiel #2
0
 private void OnGameStart(VRTK.VRTK_ControllerReference CR, bool normal)
 {
     if (!normal)
     {
         enemyManager.HardMode();
     }
     controller = CR;
     ArenaScoreDisplay.SetActive(true);
     menu.SetActive(false);
     rhythmController = Instantiate(rhythmControllerPrefab, this.transform).GetComponent <RhythmController>();
     rhythmController.StartGame(normal);
 }
 protected virtual void EngageButtonPressed(object sender, ControllerInteractionEventArgs e)
 {
     engagedController = e.controllerReference;
     active            = true;
 }
Beispiel #4
0
 /// <summary>
 /// The GetButtonAxis method retrieves the current X/Y axis values for the given button type on the given controller reference.
 /// </summary>
 /// <param name="buttonType">The type of button to check for the axis on.</param>
 /// <param name="controllerReference">The reference to the controller to check the button axis on.</param>
 /// <returns>A Vector2 of the X/Y values of the button axis. If no axis values exist for the given button, then a Vector2.Zero is returned.</returns>
 public override Vector2 GetButtonAxis(ButtonTypes buttonType, VRTK_ControllerReference controllerReference)
 {
     return(Vector2.zero);
 }
Beispiel #5
0
        /// <summary>
        /// The GetControllerButtonState method is used to determine if the given controller button for the given press type on the given controller reference is currently taking place.
        /// </summary>
        /// <param name="buttonType">The type of button to check for the state of.</param>
        /// <param name="pressType">The button state to check for.</param>
        /// <param name="controllerReference">The reference to the controller to check the button state on.</param>
        /// <returns>Returns true if the given button is in the state of the given press type on the given controller reference.</returns>
        public override bool GetControllerButtonState(ButtonTypes buttonType, ButtonPressTypes pressType, VRTK_ControllerReference controllerReference)
        {
            uint index = VRTK_ControllerReference.GetRealIndex(controllerReference);

            switch (buttonType)
            {
            case ButtonTypes.Trigger:
            case ButtonTypes.TriggerHairline:
                return(GetControllerButtonState(index, "Trigger", pressType));

            case ButtonTypes.Grip:
            case ButtonTypes.GripHairline:
                return(GetControllerButtonState(index, "Grip", pressType));

            case ButtonTypes.Touchpad:
                return(GetControllerButtonState(index, "TouchpadPress", pressType));

            case ButtonTypes.ButtonOne:
                return(GetControllerButtonState(index, "ButtonOne", pressType));

            case ButtonTypes.ButtonTwo:
                return(GetControllerButtonState(index, "ButtonTwo", pressType));

            case ButtonTypes.StartMenu:
                return(GetControllerButtonState(index, "StartMenu", pressType));
            }
            return(false);
        }
Beispiel #6
0
 /// <summary>
 /// The GetControllerOrigin method returns the origin of the given controller.
 /// </summary>
 /// <param name="controllerReference">The reference to the controller to retrieve the origin from.</param>
 /// <returns>A Transform containing the origin of the controller.</returns>
 public override Transform GetControllerOrigin(VRTK_ControllerReference controllerReference)
 {
     return(controllerReference.actual.transform);
 }
Beispiel #7
0
 /// <summary>
 /// The HapticPulse/2 method is used to initiate a simple haptic pulse on the tracked object of the given controller reference.
 /// </summary>
 /// <param name="controllerReference">The reference to the tracked object to initiate the haptic pulse on.</param>
 /// <param name="strength">The intensity of the rumble of the controller motor. `0` to `1`.</param>
 public override void HapticPulse(VRTK_ControllerReference controllerReference, float strength = 0.5f)
 {
 }
Beispiel #8
0
 /// <summary>
 /// The HapticPulse/2 method is used to initiate a haptic pulse based on an audio clip on the tracked object of the given controller reference.
 /// </summary>
 /// <param name="controllerReference">The reference to the tracked object to initiate the haptic pulse on.</param>
 /// <param name="clip">The audio clip to use for the haptic pattern.</param>
 public abstract bool HapticPulse(VRTK_ControllerReference controllerReference, AudioClip clip);
Beispiel #9
0
 /// <summary>
 /// The GetAngularVelocity method is used to determine the current angular velocity of the tracked object on the given controller reference.
 /// </summary>
 /// <param name="controllerReference">The reference to the tracked object to check for.</param>
 /// <returns>A Vector3 containing the current angular velocity of the tracked object.</returns>
 public abstract Vector3 GetAngularVelocity(VRTK_ControllerReference controllerReference);
Beispiel #10
0
 /// <summary>
 /// The GetControllerRenderModel method gets the game object that contains the given controller's render model.
 /// </summary>
 /// <param name="controllerReference">The reference to the controller to check.</param>
 /// <returns>A GameObject containing the object that has a render model for the controller.</returns>
 public abstract GameObject GetControllerRenderModel(VRTK_ControllerReference controllerReference);
Beispiel #11
0
 /// <summary>
 /// The HapticPulse/2 method is used to initiate a simple haptic pulse on the tracked object of the given controller reference.
 /// </summary>
 /// <param name="controllerReference">The reference to the tracked object to initiate the haptic pulse on.</param>
 /// <param name="strength">The intensity of the rumble of the controller motor. `0` to `1`.</param>
 public abstract void HapticPulse(VRTK_ControllerReference controllerReference, float strength = 0.5f);
Beispiel #12
0
 /// <summary>
 /// The GetControllerOrigin method returns the origin of the given controller.
 /// </summary>
 /// <param name="controllerReference">The reference to the controller to retrieve the origin from.</param>
 /// <returns>A Transform containing the origin of the controller.</returns>
 public abstract Transform GetControllerOrigin(VRTK_ControllerReference controllerReference);
Beispiel #13
0
 /// <summary>
 /// The ProcessFixedUpdate method enables an SDK to run logic for every Unity FixedUpdate
 /// </summary>
 /// <param name="controllerReference">The reference for the controller.</param>
 /// <param name="options">A dictionary of generic options that can be used to within the fixed update.</param>
 public abstract void ProcessFixedUpdate(VRTK_ControllerReference controllerReference, Dictionary <string, object> options);
Beispiel #14
0
 protected virtual VRTK_ControllerReference GetControllerReference(GameObject reference = null)
 {
     reference = (reference == null && controllerEvents != null ? controllerEvents.gameObject : reference);
     return(VRTK_ControllerReference.GetControllerReference(reference));
 }
Beispiel #15
0
 protected virtual Vector3 GetRightControllerPosition()
 {
     return(VRTK_ControllerReference.IsValid(rightControllerReference) ? rightControllerReference.actual.transform.localPosition : Vector3.zero);
 }
Beispiel #16
0
 /// <summary>
 /// The GetButtonAxis method retrieves the current X/Y axis values for the given button type on the given controller reference.
 /// </summary>
 /// <param name="buttonType">The type of button to check for the axis on.</param>
 /// <param name="controllerReference">The reference to the controller to check the button axis on.</param>
 /// <returns>A Vector2 of the X/Y values of the button axis. If no axis values exist for the given button, then a Vector2.Zero is returned.</returns>
 public abstract Vector2 GetButtonAxis(ButtonTypes buttonType, VRTK_ControllerReference controllerReference);
Beispiel #17
0
        protected virtual void Rotate()
        {
            if (!rotationActivated)
            {
                return;
            }

            if (rotationTrackingController == TrackingController.BothControllers && VRTK_ControllerReference.IsValid(leftControllerReference) && VRTK_ControllerReference.IsValid(rightControllerReference))
            {
                Vector2 currentRotationAngle = GetControllerRotation();
                float   newAngle             = Vector2.Angle(currentRotationAngle, previousRotationAngle) * Mathf.Sign(Vector3.Cross(currentRotationAngle, previousRotationAngle).z);
                RotateByAngle(newAngle);
                previousRotationAngle = currentRotationAngle;
            }
            else
            {
                float leftControllerAngle  = (TrackingControllerEnabled(rotationTrackingController, TrackingController.LeftController, rotationLeftControllerActivated) ? VRTK_DeviceFinder.GetControllerAngularVelocity(leftControllerReference).y : 0f);
                float rightControllerAngle = (TrackingControllerEnabled(rotationTrackingController, TrackingController.RightController, rotationRightControllerActivated) ? VRTK_DeviceFinder.GetControllerAngularVelocity(rightControllerReference).y : 0f);
                RotateByAngle(leftControllerAngle + rightControllerAngle);
            }
        }
Beispiel #18
0
 /// <summary>
 /// The GetButtonHairlineDelta method is used to get the difference between the current button press and the previous frame button press.
 /// </summary>
 /// <param name="buttonType">The type of button to get the hairline delta for.</param>
 /// <param name="controllerReference">The reference to the controller to get the hairline delta for.</param>
 /// <returns>The delta between the button presses.</returns>
 public abstract float GetButtonHairlineDelta(ButtonTypes buttonType, VRTK_ControllerReference controllerReference);
Beispiel #19
0
 /// <summary>
 /// The GetControllerRenderModel method gets the game object that contains the given controller's render model.
 /// </summary>
 /// <param name="controllerReference">The reference to the controller to check.</param>
 /// <returns>A GameObject containing the object that has a render model for the controller.</returns>
 public override GameObject GetControllerRenderModel(VRTK_ControllerReference controllerReference)
 {
     return(controllerReference.scriptAlias.transform.parent.FindChild("Hand").gameObject);
 }
Beispiel #20
0
 /// <summary>
 /// The GetControllerButtonState method is used to determine if the given controller button for the given press type on the given controller reference is currently taking place.
 /// </summary>
 /// <param name="buttonType">The type of button to check for the state of.</param>
 /// <param name="pressType">The button state to check for.</param>
 /// <param name="controllerReference">The reference to the controller to check the button state on.</param>
 /// <returns>Returns true if the given button is in the state of the given press type on the given controller reference.</returns>
 public abstract bool GetControllerButtonState(ButtonTypes buttonType, ButtonPressTypes pressType, VRTK_ControllerReference controllerReference);
Beispiel #21
0
 /// <summary>
 /// The HapticPulse/2 method is used to initiate a haptic pulse based on an audio clip on the tracked object of the given controller reference.
 /// </summary>
 /// <param name="controllerReference">The reference to the tracked object to initiate the haptic pulse on.</param>
 /// <param name="clip">The audio clip to use for the haptic pattern.</param>
 public override bool HapticPulse(VRTK_ControllerReference controllerReference, AudioClip clip)
 {
     //Return true so it just always prevents doing a fallback routine.
     return(true);
 }
Beispiel #22
0
 /// <summary>
 /// The GetControllerOrigin method returns the origin of the given controller.
 /// </summary>
 /// <param name="controllerReference">The reference to the controller to retrieve the origin from.</param>
 /// <returns>A Transform containing the origin of the controller.</returns>
 public override Transform GetControllerOrigin(VRTK_ControllerReference controllerReference)
 {
     return(controllerReference != null && controllerReference.actual != null ? controllerReference.actual.transform : null);
 }
Beispiel #23
0
 /// <summary>
 /// The GetButtonHairlineDelta method is used to get the difference between the current button press and the previous frame button press.
 /// </summary>
 /// <param name="buttonType">The type of button to get the hairline delta for.</param>
 /// <param name="controllerReference">The reference to the controller to get the hairline delta for.</param>
 /// <returns>The delta between the button presses.</returns>
 public override float GetButtonHairlineDelta(ButtonTypes buttonType, VRTK_ControllerReference controllerReference)
 {
     return(0f);
 }
Beispiel #24
0
 /// <summary>
 /// The GetButtonSenseAxis method retrieves the current sense axis value for the given button type on the given controller reference.
 /// </summary>
 /// <param name="buttonType">The type of button to check for the sense axis on.</param>
 /// <param name="controllerReference">The reference to the controller to check the sense axis on.</param>
 /// <returns>The current sense axis value.</returns>
 public override float GetButtonSenseAxis(ButtonTypes buttonType, VRTK_ControllerReference controllerReference)
 {
     return(0f);
 }
Beispiel #25
0
 /// <summary>
 /// The ProcessFixedUpdate method enables an SDK to run logic for every Unity FixedUpdate
 /// </summary>
 /// <param name="controllerReference">The reference for the controller.</param>
 /// <param name="options">A dictionary of generic options that can be used to within the fixed update.</param>
 public override void ProcessFixedUpdate(VRTK_ControllerReference controllerReference, Dictionary <string, object> options)
 {
 }
Beispiel #26
0
 /// <summary>
 /// The GetCurrentControllerType method returns the current used ControllerType based on the SDK and headset being used.
 /// </summary>
 /// <param name="controllerReference">The reference to the controller to get type of.</param>
 /// <returns>The ControllerType based on the SDK and headset being used.</returns>
 public override ControllerType GetCurrentControllerType(VRTK_ControllerReference controllerReference = null)
 {
     return(ControllerType.Simulator_Hand);
 }
Beispiel #27
0
 public void PlayHaptic(VRTK.VRTK_ControllerReference controllerReference, float strength, float duration, float interval)
 {
     VRTK.VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, strength, duration, interval);
 }
Beispiel #28
0
 protected virtual void SetControllerReferences()
 {
     leftControllerReference  = VRTK_DeviceFinder.GetControllerReferenceLeftHand();
     rightControllerReference = VRTK_DeviceFinder.GetControllerReferenceRightHand();
 }
Beispiel #29
0
 public void HapticPulse(VRTK.VRTK_ControllerReference controllerReference, float strength, float duration, float interval)
 {
     VRTK.VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, Mathf.Clamp(strength, 0, 1.0f), duration, interval);
 }
Beispiel #30
0
 protected virtual void ControllerModelAvailable(object sender, ControllerInteractionEventArgs e)
 {
     leftControllerReference  = VRTK_DeviceFinder.GetControllerReferenceLeftHand();
     rightControllerReference = VRTK_DeviceFinder.GetControllerReferenceRightHand();
 }