Switching Between Controller Movement and Teleportation

Hi All,

Our Team and I are going to implement the controller movement (smooth locomotion using the thumbstick) as an alternative locomotion method to the standard teleportation.

Below I am posting a code snippet where we try to switch between the 2 locomotion methods:

if (vrJoystickLocomotion) {
  fm.disableFeature(WebXRMotionControllerTeleportation.Name);
  fm.enableFeature(WebXRControllerMovement.Name, "latest", {
    xrInput: xrHelper.input,
    movementOrientationFollowsViewerPose: true, // default true
    movementSpeed: 0.075,
    rotationSpeed: 0.25
  });
} else {
  fm.disableFeature(WebXRControllerMovement.Name);
  xrHelper.teleportation = fm.enableFeature(
    WebXRMotionControllerTeleportation.Name,
    "stable" /* or latest */,
    {
      xrInput: xrHelper.input,
      floorMeshes: []
    }
  );

Unfortunately, this doesn’t work as the problem seems to be caused by disableFeature() not sorting any effect.

Therefore we end up getting these 2 errors depending on which locomotion method we start with (either controller movement or locomotion) and then try to switch to the other one:

Uncaught Error: Feature xr-controller-teleportation cannot be enabled while xr-controller-movement is enabled.

Uncaught Error: Feature xr-controller-movement cannot be enabled while xr-controller-teleportation is enabled.

Thank you for any info and help!

Tagging @RaananW as well :slight_smile:

Danilo
FRAME Team

1 Like

That’s a good one.

The “getEnabledFeatures” function is actually giving the keys of all features that were enabled (even if they are no longer enabled). It’s more of “available to be enabled”.

I’ll fix that very soon. Thanks for reporting!

2 Likes

This should solve it (tested locally) - [XR] remove disabled features from the enabled list by RaananW · Pull Request #11573 · BabylonJS/Babylon.js (github.com)

2 Likes

Thank you for your quick response and for your help, @RaananW!

2 Likes