I’m working on controller support for my game and one of my scripts has a wasReleased command but when I used the same code but set it up for gamepads and got an error saying
“this.app.gamepads.wasReleased (pc.PAD_1, pc.PAD_FACE_1)” is not a command
if anyone knows why this is happenin and how to fix it I’m all ears.
Sincerely
William Boersma
Have you enabled gamepads in the projects settings?
@yaustar yes I have got everything working except this last thing.
How do you repro the error message?
How do you reproduce the error message? (eg which scene to load, what actions do I have to do in the app?)
@yaustar the error went away now it just does nothing
There seems to be an issue with wasPressed
that I will look at.
However, moving around with the joystick worked fine for me. If you can’t move around with your controller, try using this site to test your pad: https://gamepad-tester.com/
hey @yaustar it still doesn’t work?
can you take another look over my code and see if there is anything wrong.
also like I said before everything works fine with the controller except this.
@yaustar the error came back
[Launch.js?id=36884907&branchId=b54e717d-51a8-41a2-8464-cdf777c7a322:10]: Uncaught TypeError: this.app.gamepads.wasReleased is not a function
Hi @WilliamBoersma31,
I gave lvl11 a try and it works quite ok, I can move around without getting any error.
2 Likes
There is another forum topic about this problem. I wonder if anything has changed since then.
https://forum.playcanvas.com/t/gamepads-dont-seem-to-use-wasreleased-any-work-around/
Hi @Albertos I tried using that topic’s solution and it did nothing.
If there is still no working wasReleased
function for gamepads I think you can do something like below.
var pressed = false;
if (pressed && !this.app.keyboard.isPressed(pc.KEY_0)) {
pressed = false;
// Your wasReleased functions here
}
else if (this.app.keyboard.isPressed(pc.KEY_0)) {
pressed = true;
// Normal isPressed functions here
}
2 Likes
@Albertos how do I call pressed would it be
if (pressed) {
‘my code’
}
or
if (pressed) {
}
else {
‘my code’
}