I’m currently trying to setup a simple Virtual Reality project for mobile phones with a basic VR headset and a controller. In case it matters: I’m using a Huawei Mate 10 Pro and the Destek VR Headset V5 with its bluetooth controller.
In standard mode, I’m able to control the camera with the gamepad just fine. However, as soon as I switch to WebXR, the gamepad is not reacting anymore and the WebXRController that I find does not have a gamepad. Is there anything obvious that I am missing?
I also tried to do it with a PS4 controller - same result. However, I found a workaround by using the HTML5 Gampad API instead of the BabylonJS Gamepad API:
I can only assume that the reason this happens is because we don’t call attachControl on the WebXR camera (because it is technically not needed, WebXR has its own controller system). The Gamepad input, keyboard and mouse input, should all work the same in WebXR (as it is technically a regular FreeCamera), but the camera is not attached. Try calling attachControl on the webxr camera AFTER the xr session started and see if the events are fired.
Thanks a lot for your answer! I tried attaching the WebXR camera on the WebXRState.IN_XR event, but the events were still not firing. I’ll stick for now to the HTML5 gamepad API.