-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Input get_vector returns wrong values after switching devices #82148
Comments
Oh! I want to mention that Y returns to 0.0 after you press "up" and "down" keys. |
Can you test #82056 locally? See Testing pull requests in the documentation for instructions. |
This is controller drift, I almost opened a bug for this but I am not sure if it's intended because I had the same issue. Basically there's the anti-drift thing in the Input settings, but it applies to the whole input not just the gamepad. So if you're doing nothing, your Input.get_vector will be 0,0 If you press keyboard left, then it disables the drift threshold and you will get -1,0 combined with whatever your drift is. This means that if you press left, and your controller drift is up/down, you can start moving up even though you're pressing left. IMO it's a bug because you should apply the drift threshold only to the gamepad. However it is kinda by design. Workaround would be to get_vector twice, once on the keyboard and once on the gamepad if it's important you have both control the same character, and combine the vectors (the gamepad vector will be 0,0 if it's not moving this way). |
Yes, but as I mentioned, if you press up/down, the added drift disappear. Or this drift should be applied all the time or not at all. Also it doesn't happen with the joypad. Perhaps because keyboard only send 0 or 1. Or perhaps because the drift cap doesn't apply to keyboard? idk... So there's definitely something there because the way it works is not constant. |
I just tested the #82056 and it doesn't fix it. And after pressing the keyboard left/right/up/down it becomes like this: After pressing a key, the corresponding value of that key becomes 0. |
If you mean that you leave the joystick completely and the Y value returns to a small value when the keyboard uses the X axis, then it would indicate that some values used by the joystick are not reset in the first frame that the joystick is "unpressed" and you keep a small value. Anyway, I think that there is a chance that your issue has to do something with deadzone missunderstanding, and isn't an actual bug. If it turns out to be a bug, please share with me minimal project and I would love to be assigned to solve it. |
I don't think it's the joypad. As the drift of 0.01 on the screenshots above is too small and no other game has any kind of drifting happening yet. Also a quote from the docs:
Font: https://docs.godotengine.org/en/stable/tutorials/inputs/controllers_gamepads_joysticks.html
But yes, I also think so. After switching from joypad to keyboard, the joypad's values are not reset until you press the corresponding keys on the keyboard. So I think there's a bug there.
A minimum project is: get_vector() internally uses get_action_raw_strength(). These methods, get_action_raw_strength() and get_action_strength(), gets the value from action_state. So somewhere in action_state the values are cached. |
I'm seeing this issue as well with |
@ErezShahaf |
The solution I found was splitting the inputs (e.g., "ui_left_joy"). |
Still happening in 4.2.1 and 4.3dev1 |
Definitely still happening in 4.2.1. Easy to check with this code
Press directions on keyboard: looks fine. Move left joystick on controller: looks fine. Switch back to keyboard and press directions: wrong. Pressing left on keyboard now consistently outputs -0.75, -0.03 |
Currently, So one solution to this issue could be for Another option would be to introduce some sort of filter for analogue inputs, such that any value below a certain threshold is ignored even by a "raw" strength check. Or leave "raw" as it is, and add a Or just add a warning to the documentation, that |
Oop, unless I'm misunderstanding, this seems like the same issue as #55264? |
Working on a twinstick shooter now and according to the documentation
But if the controller is still connected it causes the character to drift a side as the residual input is picked up from the controller the moment the keyboard is used. Definitely NOT an expected behaviour and contrary to documentation, forces you to handle controller and MKB separated. Either the function should be changed or the documentation updated. |
Thanks for the report! Consolidating in #55264. |
Was it fixed? 🤔 Oh! Okay... nvm 😅 |
Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.
Godot version
4.2.dev5
System information
Windows 11
Issue description
When I press the "UI Right" key on my keyboard, I get a value for Y like 0.01937 instead of 0.0 but there is a step to reproduce this. You'll need two devices, a keyboard and a joypad.
Steps to reproduce
Minimal reproduction project
N/A
The text was updated successfully, but these errors were encountered: