Example of navigation + interaction using VR?

Thanks a lot for the extension, so much easier to test!

by user 832577308644212766

Ah good, thanks for noticing :+1: i’ll make a note of this :slight_smile:

Btw, do you know if there is a way to debug the (real) Quest browser on macos? Couldn’t find any :sweat_smile:

by user 832577308644212766

It should be same as any android debugging.https://engine.needle.tools/docs/debugging.html#android-debugging

Will try, thank you :+1:

by user 832577308644212766

Ehi guys, any idea how to properly apply rotation to WebXR Rig? Tried with this code, movement seems to work but rotation does nothing :sweat_smile:

by user 832577308644212766

start(): void {        
        this.webXR = GameObject.findObjectOfType(WebXR);                
        
        if (this.webXR) {            
            WebXR.addEventListener(WebXREvent.XRStarted, () => {            
                this.leftController = this.webXR!.Controllers[0];
                this.rightController = this.webXR!.Controllers[1];
                
                this.rightController.enableDefaultControls = false;
                this.leftController.enableDefaultControls = false;
                
                
            });
        }
    }

    update(): void {
        // Handle rotation
        if (this.rightController) {            
            const axesX = this.rightController.input?.gamepad?.axes[2];            

            if (axesX) {
                console.log('R_X_1', axesX);
                this.webXR?.setWorldRotation(0, axesX * this.context.time.deltaTime, 0);
            }            
        }

        // Handle movement
        if (this.leftController) {            
            const axesX = this.leftController.input?.gamepad?.axes[2];
            const axesY = this.leftController.input?.gamepad?.axes[3];

            if (axesX) {
                // console.log('L_X_1', axesX);
                let movementVector = new Vector3();
                movementVector.set(axesX * this.context.time.deltaTime, 0, 0);
                this.webXR?.Rig.position.add(movementVector.negate());
            }

            if (axesY) {
                // console.log('L_Y_1', axesY);
                let movementVector = new Vector3();
                movementVector.set(0, 0, axesY * this.context.time.deltaTime);
                this.webXR?.Rig.position.add(movementVector.negate());
            }
        }
    }

by user 832577308644212766

this.leftController = this.webXR!.Controllers[0];
you can use this.webXR.LeftController instead.

----

this.webXR?.setWorldRotation(0, axesX * this.context.time.deltaTime, 0);
You are setting rotation to an object the WebXR component is on. That isn’t the rig. That’s a different object.

Try:

this.webXR?.Rig.setWorldRotation(0, axesX * this.context.time.deltaTime, 0);

Oh man, my bad. Trying now

by user 832577308644212766

What is the relationship between the XRRig and the camera? I thought that the camera was inside the XRRig object but looking at the Unity scene doesn’t seem so
image.png

by user 832577308644212766

The camera is driven by the XR data, so it doesn’t matter where it is.

What are you trying to achieve?

Basically I am trying to understand how to customize controller movement with Oculus, but I am a noob in 3d graphics :sweat_smile: . The default behaviour in sample scene is to translate with left joystick (ok) and turn around with right joystick. Would like to change the turning behaviour from “steppish” to smooth

by user 832577308644212766

I am also trying a different approach, the idea is to translate in the forward gaze direction when right trigger button is pressed. Unfortunately translating the XRRIG on the Z direction doesn’t seem to take into account the gaze direction

by user 832577308644212766

Share your code, ill comment tonmorow :slight_smile:

The translate Z thing is pretty simple code:

update(): void {        
        if (this.rightController?.selectionPressed) {
            this.webXR?.Rig.translateZ(this.context.time.deltaTime);
        }
    }

by user 832577308644212766

But it doesn’t take into account gaze orientation as I thought

by user 832577308644212766

The rig doesnt automatically rotate into your look direction.

You can take the forward vector of the camera, set y to 0, normalize and add the result to the rig position when selection is pressed. (Sorry only on the phone right now so cannot really write a lot of code)

const dir = getWorldDirection(this.context.mainCamera!)

dir.y = 0; dir.normalize();

rig.position.add(dir.multiplyFactor(this.context.time.deltaTime))

Roughly like that