Custom VR-Teleportation (WebXR Controllers)

Hi everyone!
I was wondering how i would implement custom teleporting behaviour for VR (i.e. curve laser raycast instead of a staight line, display an Arrow or circle of some sort at the chosen location, and only teleport once the stick is released).

So far, i tried poking around the engine > engine-components > WebXRController.ts Component and the runTeleport function. Would there be a better way to solve this? Or is this the only approach as of now? :slightly_smiling_face:

Cheers!

Original Post on Discord

by user 263717937473519619

As of now that’s the approach

I think what you’d have to do at the moment is to override the update and onUpdate methods of the XRController (or patch the static Create method and build your own controller there - then you get full control).

The WebXRController part is on the list to be modularized to make it simpler / possible to create custom behaviours but I dont think it will happen this year

So far nobody has asked for custom behaviours so it wasnt a priority so it’s good that you ask :slightly_smiling_face:

Thanks for the fast reply! I will give it my best and post an update once i got something figured out :slightly_smiling_face:

by user 263717937473519619

Hi! is this still the way to go about it?

by user 262331051802755072

Right now yes

Hey @marcel :cactus: how is it going? Is this still the case for custom VR controllers?

by user 326444095130042368

sorry for digging this up, I’m currently trying to change something in WebXRController.ts but on build the export is still exporting an unchanged version. Is there a trick to get rid of old, cached files of the needle engine?
I’ve already tried disabling smart export and deleted the “dist” folder in the needle engine modules, that does not fix it.

by user 334342083445784576

Try clearing the vite cache (.vite folder in node_modules). But its not supported/recommended to change builtin code like that. Can you share what you changed?

Perhaps it can be patched

I don’t think it can be patched, I want to have more control on where the player teleports when pointing towards a position. I’m using TeleportTargets Gameobject instead of the Raycast Hitpoint. Players are often bugging into geometry when teleporting to meshes above them (eg. a cube).
Also, I’ve commented out the miniaturemode because on double press, player can teleport on my Three.Water and I don’t know how to set the layer of a THREE.PlaneGeometry to Ignore Raycast :smile:

  if (doTeleport) {
            if (!this.didTeleport) {
                const rc = this.raycast();
                this.didTeleport = true;
                if (rc && rc.length > 0) {
                    const hit = rc[0];
                    if (this.isValidTeleportTarget(hit.object)) {
                        const target = GameObject.getComponentInParent(hit.object, TeleportTarget);
                        if (target)
                        {
                            const point = target.gameObject.position;
                            setWorldPosition(rig, point);
                        }
                    }
                }
            }
        }

by user 334342083445784576

Vite Cache deleting isn’t doing it either. Seems I have to wait for a more extendable WebXRController as well.

by user 334342083445784576

Feature Request: More control over Teleport Destinations :wink:

by user 334342083445784576

You can set it to layer 2 and disable all other layers (using the same layer as Unity for IgnoreRaycast)

Is that one method? Sorry not on the pc right now so support is a bit slow :slightly_smiling_face: but if it is you can redefine the method to modify the behaviour

Perhaps with the @prefix decorator too. I think returning false does prevent default behaviour but im not 100% sure right now Typescript Decorators | Needle Engine Documentation

even private? That sounds awesome, will try

by user 334342083445784576

Yeah you can patch anything :slightly_smiling_face:

(same as in c# actually :slightly_smiling_face: with tools like harmony)

thx, that worked!

export class WebXRControllerExtend extends Behaviour {
    @prefix(WebXRController)
    private runTeleport(rig, buttons) {
       return false;
    }
}

by user 334342083445784576