Haptics and vibration

I’m developing a game for the oculus quest right now and Im trying to get the controllers to vibrate. I’ve tried a lot of different code examples, including stuff I’ve used in A-Frame. But when I use it it breaks. And I can’t find any documentation on how to add it.

I’ve tried:


AFAIK, haptics are only supported via the gamepad extensions. At the moment, PlayCanvas doesn’t provide an API for it so you have to get the raw pad object via this.app.gamepads.current[padIndex]

WebVr Lab gets the raw pad input too if you want to see an examplehttps://developer.playcanvas.com/en/tutorials/webvr-lab/

Do you know why my array from this snippet


would be empty? Im on the Oculus Quest. But when I look the the array here its empty.

So I opened up the chrome debugger for the Oculus browser and logged


I can see “current” as a key with an empty array as the value. So it’s as if the browser doesn’t realize that there each of my oculus controllers are active on screen.

Frustratingly, this code will work in A-Frame no problem. But when I use it in PlayCanvas it does not vibrate and throws an error that gamepad is null and you cannot call hapticActuators on null. Is PlayCanvas doing something behind the scene to block the ability to access these controls?

Vr.prototype.vibration = function(vbt){
      vbt = 0.3;
    var vibrationLength = 100;
    var gamepads = navigator.getGamepads && navigator.getGamepads();
    for (var i = 0; gamepads.length; i++) {
      var gamepad = gamepads[i];
      gamepad.hapticActuators[0].pulse(vbt, vibrationLength);
1 Like

Not as far as I know. Only thing I can think of is if the VR polyfill or browser extensions are different.