Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

HI, i am trying to get movment of the OVRPlayercontroller with the gear VR trackpad

Discussion in 'AR/VR (XR) Discussion' started by markncolleen1985, Dec 3, 2017.

  1. markncolleen1985

    markncolleen1985

    Joined:
    Nov 21, 2017
    Posts:
    5
    OK so im kind of new to unity, but i have been playing with Gear Vr now for a few weeks.

    I have learned a few things, which has helped me ask the right questions; how do i use the trackpad to move?

    I have played with the OVRPlayerController.cs and i have learned that what im trying to do is use this section of code here:


    Vector2 primaryAxis = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);

    if(primaryAxis.y > 0.0f)
    MoveThrottle += ort * (primaryAxis.y * transform.lossyScale.z * moveInfluence * Vector3.forward);

    if(primaryAxis.y < 0.0f)
    MoveThrottle += ort * (Mathf.Abs(primaryAxis.y) * transform.lossyScale.z * moveInfluence * BackAndSideDampen * Vector3.back);

    if(primaryAxis.x < 0.0f)
    MoveThrottle += ort * (Mathf.Abs(primaryAxis.x) * transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.left);

    if(primaryAxis.x > 0.0f)
    MoveThrottle += ort * (primaryAxis.x * transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.right);

    Vector2 secondaryAxis = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);

    euler.y += secondaryAxis.x * rotateInfluence;

    transform.rotation = Quaternion.Euler(euler);


    But i cannot get movement at all, i can get movement by using this command:


    if (OVRInput.Get(OVRInput.Button.DpadUp))
    {
    moveForward = true;
    dpad_move = true;

    Which makes the movement via a swipe motion, one small step at a time :/

    But i can move fluid by using this command:

    (OVRInput.Get(OVRInput.Touch.PrimaryTouchpad)) sadly this will only work in one direction

    So i am really stuck, please can somebody help me get the track pad to move?

    This is weeks on and im no where nearer being able to move foward backward :/


    Thank you for your help
     
  2. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    One thing to know about the trackpad on the HMD is that it's swipe based (unlike the one on the gear vr controller). So no matter where you touch on it 0,0 will be reported until you drag from the original location. So if you touch in the center and then drag all the way right you will get 1,0. You have to drag to get any values.
     
  3. markncolleen1985

    markncolleen1985

    Joined:
    Nov 21, 2017
    Posts:
    5

    Thank you very much for your reply, but its the gear vr controller im looking to walk with. I am baffled at what part of the script i need to use, I am thinkign that its active on playercontroller.cs by the looks of it, but somehow its not working, is it a bug or is there something i need to enable in the script mate?

    thank you for your help, Still no closer to solving it lol
     
  4. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
  5. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    Appreciate the recommendation!

    The first line in your script change it to OVRInput.Axis2D.PrimaryTouchpad. Thumbstick is for the Rift.
     
    malkie and markncolleen1985 like this.
  6. markncolleen1985

    markncolleen1985

    Joined:
    Nov 21, 2017
    Posts:
    5

    This is the answer i was looking for all working fine now :)

    Most respect to you mate, thank you very very much for helping. This will help others

    For anybody looking for this answer on the net, who is using gear vr controller with unity and cannot get the trackpad to walk just copy this and replace it with your version
     

    Attached Files:

    malkie and greggtwep16 like this.
  7. jamie2dog

    jamie2dog

    Joined:
    Jun 21, 2017
    Posts:
    4
    nearly a year old but this helped me greatly thank you! so was the only thing changed in the original script that 1 line of code mentioned above? just starting out with VR development myself and trying to master the basics like walking and grabbing objects!
     
  8. malkie

    malkie

    Joined:
    Nov 8, 2013
    Posts:
    1
    Many,many thanks!

    Been trying to pull that code apart for a couple of days now. This works perfectly.