Hi. I’m currently working on a 3D top-down game, where I have a character controlled by a gamepad. The issue i’m facing is that when the character is moving and I release the left stick of my controller quickly, my character rotates sometimes abruptly to face a direction that i’ve not set with my controller. A showcase is given down below.
It is from the accurate reading of your controller, you need to add a dead zone to however you are getting your input because when you let go of stick the it doesn’t center to 0,0 all the time.
Lets say you are holding the stick full left and then let go the values could look like this:
X = 1.0
then you let go
X = -0.1
instead of going to center it has a slight deviation because of the accuracy of your input function.
Are you normalizing your input before this if statement? If so try to remove that, especially if using Input.get_vector otherwise you can use limit_length(1.0) instead for potentially better results
Input.get_vector has a deadzone parameter, though I never used it, don’t know hot it works, you could try passing 0.05 or 0.1 maybe. And from the input length value on your screen it looks like you’re normalizing the input, you probably shouldn’t do that for a controller, as already said above.
Interesting, I noticed the “Input Length: 1.0” label at the top of the screen, but it was only every 0.0 or 1.0, so it seems to be normalized somewhere or you are terribly quick with the stick, or I guess the label could be wrong. Anyway if you show more of the controller script that may help.
Oh sorry, i’m getting confused with all my scripts !
In my UI script i have floored the input value, this is why you only see 0 or 1 : %Label.text = str(floorf(action.move().length())), as action.move() is a input vector declared in an Autoload script:
So I’ve used the Input.get_vector() method with 0.5 as deadzone, after reading the doc, and I’ve set the deadzone of the four axis in Project Settings to 0. For now the problem seems to be fixed, but i’ll explore all the others possibilities. Thank you very much !
I suspect something is wrong with your code. For example why is liable not showing values between 0 and 1. Try to map it to arrow keys and see if it has same issue.