Search Unity

How can I create a Continuous Turn Provider in VR??? Please help..

Discussion in 'VR' started by Mikeramczyk1977, Sep 17, 2020.

  1. Mikeramczyk1977

    Mikeramczyk1977

    Joined:
    Jul 12, 2020
    Posts:
    58
    How can I create a Continuous Turn Provider in VR???

    I see the premade snap turn provider in Unity, but I need to create a continuous turn provider, I am fairly new to coding anything at all for unity, but this is a must have on my current game setup for the game I am trying to create in VR.
    Can anyone please help?
     
  2. MattESqr

    MattESqr

    Joined:
    Feb 5, 2020
    Posts:
    15
    If you mean something like "hold left joystick and slowly rotate left", then you could do something like

    Code (CSharp):
    1.  Transform myXRRigTransform;
    2.         if (device.TryGetFeatureValue(primary2DAxisUsage, out primary2DAxisValue))
    3.         {
    4.             float turnSpeed = 30 * Time.deltaTime;
    5.             float leftOrRight = primary2DAxisValue.x;
    6.             myXRRigTransform.RotateAround(Vector3.up * turnSpeed * leftOrRight, Space.Self);
    7.         }
    The input stuff for XR in Unity is a bit of a mess in my opinion, so that first if statement is really just "Is there value on the joystick?" - which can be determined a number of ways depending on the input approach you used
     
  3. Mikeramczyk1977

    Mikeramczyk1977

    Joined:
    Jul 12, 2020
    Posts:
    58
    I am trying to assign to only the right Oculus Thumbstick.
     
  4. Mikeramczyk1977

    Mikeramczyk1977

    Joined:
    Jul 12, 2020
    Posts:
    58
    I am still fairly new to Unity, and I am not entirely sure how to set this up to 9nly listen to the right Controller.
     
  5. Mikeramczyk1977

    Mikeramczyk1977

    Joined:
    Jul 12, 2020
    Posts:
    58
    HOW CAN I MAKE THIS WORK ONLY ON MY RIGHT HAND??????? PLEASE HELPPPPPPPPP!!!!!

    Code (CSharp):
    1.  
    2.  
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using UnityEngine;
    6. using UnityEngine.XR;
    7. using UnityEngine.XR.Interaction.Toolkit;
    8.  
    9. public class ContinuousMovement2 : MonoBehaviour
    10. {
    11.    
    12.     public float speed = 1;
    13.     public XRNode inputSource;
    14.     public float  RotateSpeed = 5;
    15.     private XRRig rig;
    16.     private Vector2 inputAxis;
    17.     private CharacterController character;
    18.    
    19.  
    20.     // Start is called before the first frame update
    21.     void Start()
    22.     {
    23.         character = GetComponent<CharacterController>();
    24.         rig = GetComponent<XRRig>();
    25.     }
    26.  
    27.     void Update()
    28.     {
    29.         InputDevice device = InputDevices.GetDeviceAtXRNode(inputSource);
    30.         device.TryGetFeatureValue(CommonUsages.primary2DAxis, out inputAxis);
    31.  
    32.  
    33.     }
    34.  
    35.     // Update is called once per frame
    36.  
    37.     private void FixedUpdate()
    38.     {
    39.  
    40.         transform.Rotate(0, Input.GetAxisRaw("Horizontal") * RotateSpeed, 0);
    41.  
    42.     }
    43.  
    44. }
    45.  
    46.