Search Unity

First person locomotion using Oculus Go Controller with Oculus Integration Asset

Discussion in 'AR/VR (XR) Discussion' started by avinash_unity542, Dec 14, 2018.

  1. avinash_unity542

    avinash_unity542

    Joined:
    Sep 28, 2018
    Posts:
    15
    Hi,
    I'm using the Oculus Integration package from asset store to get the basic packages for Oculus Go VR development with Unity. I used the OVRPlayerController prefab, but I'm unable to move the character using the controller, whereas when I run the scene in unity, I'm able to move using WASD and rotate left/right using Q and E keys. Since this is a VR package, how come its not working for Oculus Go Controller but only for keyboard? Please help
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I don't know an answer to your question, but for what it's worth, I've been doing quite a lot of development for Oculus Go lately, and I don't use the OVRPlayerController prefab. Oculus's sample code makes everything way more complicated than it needs to be.

    Instead I suggest you just make your own movement controller. Depending on what style of movement you want to do, this can be as easy as detecting a touch on the thumb disc, and setting your navMeshAgent.velocity accordingly. Something like:

    Code (CSharp):
    1.         Vector3 targetVelocity = Vector3.zero;
    2.         if (OculusInput.IsDiscTouched()) {
    3.             if (touchDownTime == 0) touchDownTime = Time.time;
    4.             float timeSinceDown = Time.time - touchDownTime;
    5.             Vector2 pos = OculusInput.GetDiscTouchPos();
    6.             float throttle = throttleCurve.Evaluate(pos.magnitude);
    7.             if (Mathf.Abs(pos.x) > Mathf.Abs(pos.y) && timeSinceDown < sideTouchDelay) throttle = 0;
    8.             if (throttle > 0.01f) {
    9.                 if (pos.y < 0) pos.y *= reverseSpeedFactor;
    10.                 targetVelocity = forward * speed * throttle * pos.y
    11.                     + right * speed * throttle * pos.x * sideSpeedFactor;
    12.             }
    13.         } else {
    14.             touchDownTime = 0;
    15.         }
    16.         velocity = Vector3.MoveTowards(velocity, targetVelocity, acceleration * Time.deltaTime);
    17.         moveLimiter.SetVelocity(velocity);
    18.  
    OculusInput is my own little helper module, here are the relevant methods from that:

    Code (CSharp):
    1.     public static bool IsDiscTouched() {
    2.         #if UNITY_EDITOR
    3.         if (Input.GetKey(KeyCode.W)) {
    4.             _instance.touchDownPos = new Vector2(0, 1);
    5.             _instance.touchDownTime = Time.time;
    6.         }
    7.         return (Time.time < _instance.touchDownTime + 0.1f);
    8.         #else
    9.         return OVRInput.Get(OVRInput.Touch.PrimaryTouchpad);
    10.         #endif
    11.     }
    12.    
    13.     public static Vector2 GetDiscTouchPos() {
    14.         #if UNITY_EDITOR
    15.         return _instance.touchDownPos;
    16.         #else
    17.         return OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad);
    18.         #endif
    19.     }
    Also: let me recommend you join a Discord server called GOmmunity. There are a lot of enthusiastic players and developers there (including me) who will be glad to help you out.