- Home /
Steam VR touchpad to rotate object
Hi there!
I'm actually developing a system for a car, and I'm trying to remap the wheels' rotation to the Vive controller's touch-pad.
First thing I Tried was linking the wheels to an empty object, and parent the touch-pad X and Y with the empty object's position, but it didn't work.
Then I tried getting X and Y from the touch-pad and rotate the desired gameObject by passing the value trough gameObject's rotation.
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 
 public class Touchpad : MonoBehaviour {
 
     SteamVR_Controller.Device device;
     SteamVR_TrackedObject trackedobj;
     
     public GameObject wheelL;
     public GameObject wheelR;
 
     public float multiplier = 30;
     
     Vector2 touchpad;
 
     private float sensitivity = 3.5f;
 
     void Start ()
        {
         trackedobj = GetComponent<SteamVR_TrackedObject>();
         device = SteamVR_Controller.Input((int)trackedobj.index);
     }
 
 
     void Update ()
     {
         float tiltAroundX = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).x;
         float tiltAroundY = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).y;
 
         if (device.GetTouch(SteamVR_Controller.ButtonMask.Touchpad)) 
        {
             wheelL.transform.Rotate(0, 0, tiltAroundX);
         }
 
         if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
         {
             wheelL.transform.Rotate(0, 0, 0);
         }
     }
 }
But it accelerates the speed of the rotation, the more you touch the pad to a side, the more fast it rotates, and the rotation doesn't reset after the touch-pad is released. Is there any idea of how can the touch-pad's input be taken to rotate with no acceleration, and reset the object's rotation on release?
Answer by Paramotion · Jan 25, 2017 at 03:26 PM
Instead of using
"wheelL.transform.Rotate(0, 0, tiltAroundX);"
use
"wheelL.transform.localRotation = Quaternion.Euler(0, 0, tiltAroundX);"
Your answer
 
 
             Follow this Question
Related Questions
Flip over an object (smooth transition) 3 Answers
SteamVR error 109 issues 1 Answer
How to get controller input when using the SteamVR Interaction System 2 Answers
Distribute terrain in zones 3 Answers
Menu scrolling with Vive Touchpad? 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                