Gamepad help please

ok thanks.

hey @yaustar while i have your attention how would i make the mouse follow the right stick? if I can. also how would i make R2 count as a click.

@Leonidas can you help with this?

I dont know how to do that but if there was something that you make an object and control it with the gamepad axis you could put the mouse position on the object that the axis is controlling. Is there anything like that in playcanvas?. I think there is.

For the second question there is a function called fire(); so that you can make fire be a mouse click and a gamepad press at the same time. Like fire = "//put the mouse click and gamepad press here"; So you can then add if(fire){//add your function here}

I hope it helps @WilliamBoersma31.

Hey so this thread has been super helpful and I was able to get real time data from my ds4 controller working fine. The only issue is that the L2 and R2 triggers seem to be treated as buttons and I cannot get their axis values. Is this a limitation or am I just doing something wrong? Here is my playcanvas project for this https://playcanvas.com/project/797941/overview/controllerinputtest.

One other issue that Iā€™m facing is that I canā€™t seem to get my controller detected in firefox. I tested on chrome and edge and both work fine. I also had similar results with gamepad api https://gamepad-tester.com/.

Unfortunately, our game pad API doesnā€™t handle analogue buttons so this would need to be a feature request.

In the meantime, you can use the browser gamepad API directly as PlayCanvas only does a lightweight wrapper around it: https://developer.mozilla.org/en-US/docs/Web/API/Gamepad or use a third party library: https://samiare.github.io/Controller.js/

Iā€™m afraid thatā€™s an issue with the browser if other game testers are having the same issue.

1 Like