Search code examples
javascriptaframe

A-Frame only show vive controls if they exist


Is there a way to only show Vive controllers from A-Frame if they are actually connected. But if not do not show the controllers?

https://aframe.io/docs/master/components/vive-controls.html


Solution

  • You could write a component to hide the controllers if they aren't found:

    AFRAME.registerComponent('hide-if-no-controllers', {
      init: function () {
        if (this.sceneEl.systems['tracked-controls'].controllers.length) { return; }  // Alternatively, use navigator.getGamepads().
        this.setAttribute('visible', false);
      }
    });