Hey everyone,
I’ve gotten gamepads mostly setup, but I’m having issues with changing the sensitivity and deadzones.
I changed the sensitivity by changing the camera.gamepadAngularSensibility. When I set it to very high (low sensitivity), the deadzones seem to be massive. But when I set this to be very low (high sensitivity), the deadzone is brutal - the joystick sitting still will still fly around the screen.
I have found a couple of posts on this forum from a couple years ago that “solve” the deadzone problem, but after trying them, I can’t get their solutions to work as they don’t effect the camera rotation.
Changing the values in the function:
gamepad.onrightstickchanged((values) => {
values.x = 0;
values.y = 0;
});
Has no effect, so unless there’s another way I can manually manipulate the camera rotation from the joystick input values, I’m not sure how I can add deadzones.
Here’s a playground:
https://playground.babylonjs.com/#TF57ZU
Press up/down on the DPad to change the sensitivity. It will console.log the new values.
Also, in the onrightstickchanged function I try setting the values to 0 just to test stopping the joystick rotation entirely, but with no success.
I’m mostly wanting to know the best practice of changing/overriding the camera rotation before the joystick makes it’s changes.
Still haven’t gotten anywhere on this, anyone have any ideas?
Pinging @PolygonalSun again, he is back and should be available
It seems that only UniversalCamera has the property gamepadAngularSensibility. I have successfully used ArcRotateCamera with dual shock pad and I have to write my own code to rotate the camera. Basically, I have a method called isRightStickIdle() which returns a boolean after evaluating the expression
values.x * values.x + values.y*values.y < delta
where delta is set to 0.02 by default. The camera is rotated by incrementing its alpha value by +0.01 or -0.01 when the stick moved left or right.
Dual shock pads, especially old ones, may call the onrightstickchanged() even when you do not touch the stick. As far as I know, game developers have to compensate for it by ignoring small displacements.
Gotcha, yeah I’m looking to do something similar but with the UniversalCamera, just can’t seem to figure out where exactly I can modify how the camera handles the input of the joystick.
Even changing the camera.inputs.attached.gamepad.checkInputs() function has no effect, which is where it appears to be applying the angularSensibility. Hoping @PolygonalSun has some insight
Hey @morterra,
First of all, the reasons why you’re seeing such a disparity in the deadzones is with how the right stick’s values are calculated and handled. By default, we use a deadzone delta of 0.001
for our right stick. The code that calculates the values is:
var RSValues = this.gamepad.rightStick;
if (RSValues) {
var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
var normalizedRY = (RSValues.y / this.gamepadAngularSensibility) * this._yAxisScale;
RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
} else {
RSValues = { x: 0, y: 0 };
}
The issue with this is that deadzone check happens after we apply the sensibility. I’m currently working on a fix and will have it in PR later today.