Jump to content

Locomotion and Oculus stick


AlGolden

Recommended Posts

Hi, could you please help me with locomotion. 

1. Do VIU have  a method to move player not by teleporting but by smothly moving with tuchpad or oculus stick ? 

2. To do it by myself I tried to read position of stick on Oculus Quest controller with ViveInput.GetPadAxis. But it always return (0,0). Maybe it is wrong method? @chengnay

Link to comment
Share on other sites

@AlGolden Could you list the versions of your plugins including Oculus SDK (Unity XR or Unity Native), VIU, Unity Plugin... etc? Thanks!

 

UPDATE: Regarding the ViveInput.GetPadAxis, did you assign the correct role? I tried using Oculus Rift Controller and Index Controller, I am able to get axis value.

Could you provide sample code for debugging?

Link to comment
Share on other sites

@chengnay Unity 2019.4.11f1, Oculus XR Plugin 1.5.0, Unity XR Plugin Management 3.2.13 (today swiitched to 3.2.16), XR Legacy Input Helpers 2.1.4, VIU 1.12.0.0

Grip and Trigger works fine on both left and right Oculus Quest Controllers, so the roles are correct.

Both ViveInput.GetPress(handRole, ControllerButton.Grip) and  ViveInput.GetTriggerValue(handRole) works.

But ViveInput.GetPadAxis(handRole) returns always (0,0);

Script:

// Animating controller that updates with the tracked controller.
public class TouchController : MonoBehaviour
 {
    [SerializeField]
    protected Animator m_animator = null;
    [SerializeField]
    protected HandRole handRole;


    private void Update()
    {
        Vector2 v2 = ViveInput.GetPadAxis(handRole);
        Debug.Log(v2.x.ToString() + "  " + v2.y.ToString());     

        m_animator.SetFloat("Grip", ViveInput.GetPress(handRole, ControllerButton.Grip) ? 1.0f : 0.0f);
        m_animator.SetFloat("Trigger", ViveInput.GetTriggerValue(handRole));
    }

}

Link to comment
Share on other sites

@AlGolden Thanks for pointing out the bug.

Please update Assets/HTC.UnityPlugin/VRModule/Modules/UnityXRModule.cs,

Line 661,

state.SetAxisValue(VRModuleRawAxis.TouchpadX, primary2DAxis.x);
state.SetAxisValue(VRModuleRawAxis.TouchpadY, primary2DAxis.y);

 

Regarding the locomotion, VIU does not have smooth moving with touchpad or joystick, do you need us to provide sample code?

Link to comment
Share on other sites

@AlGolden I found this sample online,

You might need to do some modifications.

Replace Input.GetAxis("Horizontal") by ViveInput.GetAxis(role, ControllerAxis.PadX)

Replace Input.GetAxis("Vertical") by ViveInput.GetAxis(role, ControllerAxis.PadY)

And Input.GetButtonDown("Jump") to any button as you wish.

I just add this script to VROrigin and move with Touchpad.

You will need to adjust the moving speed.

Link to comment
Share on other sites

Thanks a lot! One more question. I try to dectect what hardware uses the app - Vive Focus, Oculus Quest or HMD is absent,

I call VRModule.GetDeviceState(0).deviceModel in GameObject.Start().  Bur it seems it's not a safe way. Sometimes it returns "OculusHMD" but sometimes "Unknown".

I thought it's because VRModule could be not initialised at the the time of the call and move it to Update(). But it's the same unpredictable. What is the right way to detect the hardware?

Link to comment
Share on other sites

@chengnay We have a start scene where teach user how to use controlers. Since Quest and Focus have different controllers (we use our customized  models) the scenario is slightly different. So i need to know which scenrio to use. We also use the same app on a tablet connected with the helmet by Wifi using Mirror sdk in a slavemode so i need to know which model to show on a slave tablet. Now I simply state the HMD type at compile time but it's not very convinient during development. It would be much better to understand HMD type or it's abcense at runtime.

Edited by AlGolden
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...