Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Rotating object with Gear/Go controller touchpad (SOLVED)

Discussion in 'AR/VR (XR) Discussion' started by Anne_Lanting, Mar 4, 2019.

  1. Anne_Lanting

    Anne_Lanting

    Joined:
    Dec 12, 2016
    Posts:
    25
    Hello,
    In Unity 2017.4 i had a script to rotate in object with the touchpad of the controller, Gear-vr and Go. I started a new project in Unity 2018.3 (oculus integration 1.34), and used te same script. But it doesn't work anymore. This is the script:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class KE_ObjectRotation : MonoBehaviour
    6. {
    7.  
    8.     public GameObject ObjectToRotate;
    9.     Vector3 objRotation = new Vector3(0f, 0f, 0f);
    10.     public float objRotationSpeed = 60f;
    11.     // Start is called before the first frame update
    12.     void Start()
    13.     {
    14.      
    15.     }
    16.  
    17.     // Update is called once per frame
    18.     void Update()
    19.     {
    20.         float TrackpadX = Input.GetAxis("Oculus_GearVr_DpadX");
    21.  
    22.         if (TrackpadX != 0f)
    23.         {
    24.             objRotation.y += TrackpadX * Time.deltaTime * objRotationSpeed;
    25.             ObjectToRotate.transform.rotation = Quaternion.Euler(objRotation);
    26.         }
    27.     }
    28. }

    Anyone understanding the problem?

    Anne
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    My guess is that "Oculus_GearVr_DpadX" is no longer an axis that is mapped to the track pad. The reliable way to get the trackpad input is to use OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).
     
  3. Anne_Lanting

    Anne_Lanting

    Joined:
    Dec 12, 2016
    Posts:
    25
    Turns out i made a mistake in the code: GearVr should be GearVR. Then it works properly.

    Anne
     
  4. conan222

    conan222

    Joined:
    Dec 15, 2018
    Posts:
    26
    Hi,

    Can I please jump in on this thread and ask a couple of questions.

    I've set up the same code in a demo scene and can rotate a 3d cube left or right using the touchpad which is fantastic and many thanks for sharing :)

    I would like to have 4 animal objects that can rotate individually so it possible to rotate a single object only when the laser is on it rather than just anytime I touch the touchpad? I'm using Curved UI from the Asset store and it has a Curved UI laser pointer built in which I use to interact with objects.

    Also what are the chances of rotating vertically also and not just horizontally or am I really pushing my luck with that request :rolleyes:

    Many thanks,

    Andrew
     
  5. Anne_Lanting

    Anne_Lanting

    Joined:
    Dec 12, 2016
    Posts:
    25
    Hi Andrew,

    Happy to share the code and that it is helpful to you. I think it should be possible to rotate an single object when a laserpointer is hitting it. However it is good to now what code/script you are using to interact with the object with the Curved UI laserpointer. There are many ways to achieve that, so a preview of your script would be helpful.

    Not sure if it is possible to rotate around te x and y axes with only the touchpad. If you change objRotation.y to objRotation.z, the object should rotate around the z-axes. Didn't try this so.. You could use the primary.index.trigger to switch between y and z axes.

    Anne.
     
  6. conan222

    conan222

    Joined:
    Dec 15, 2018
    Posts:
    26
    Thanks for getting in touch Anne. Appreciate it.

    I've zipped and attached the CurvedUI directory from the asset folder in my project. I initially purchased and installed via the Unity editor so not sure if it works when just drag an dropped into your own project folder? There's some demo scenes included in the folder and my project is based on the 13 OculusVR Starter 1 scene as it already had a scrolling gui window that I needed for something else.

    I have an object rotating left and right using the touch pad and your script but as previously mentioned I'm trying to make this happen only when the laser is on it, then I can add 3 other objects to the scene and do the same thing individually.

    After that I will work out how to pick up a 3d object with the laser / trigger and drop it using Oculus Go and Gear VR.

    Quite new to all this Unity thing but enjoying it.

    Andrew

    *************************
    Damn..... really sorry about that. Have just deleted the zip file attachment. I didn't think the asset would work off the bat as it was originally purchased via the Unity editor window and imported etc. and just wanted to show Anne the script files.

    *************************
     
    Last edited: Mar 8, 2019
  7. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Yikes! Please do not post the CurvedUI code publicly! That is a paid asset. The author wants and deserves to make money on it, so he can continue to support it; it's hard for him to do that if you're just giving his stuff away to the entire Internet. Please edit or delete the post above ASAP (@conan222).
     
    MadeFromPolygons likes this.
  8. Anne_Lanting

    Anne_Lanting

    Joined:
    Dec 12, 2016
    Posts:
    25
    YES ASAP. Thank you.

    Anne
     
  9. Anne_Lanting

    Anne_Lanting

    Joined:
    Dec 12, 2016
    Posts:
    25
    You should take a look at the unity vr samples (package in the asset store). It has a scene 'interactiveItem', i think that will get you started.

    Greet Anne
     
    JoeStrout likes this.
  10. conan222

    conan222

    Joined:
    Dec 15, 2018
    Posts:
    26
    Thanks Anne. I'll have a look at the different rotation methods you mentioned.

    I had tried those VR samples before and some good info but nothing in regards to picking up objects.
     
  11. Anne_Lanting

    Anne_Lanting

    Joined:
    Dec 12, 2016
    Posts:
    25
    Confused... you question was about rotating object separately, not about picking up objects.

    ?

    Anne