godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
86.31k stars 19.21k forks source link

Analog action deadzones interfere with key-based actions strength #93396

Open JoNax97 opened 1 week ago

JoNax97 commented 1 week ago

Tested versions

System information

Godot v4.1.4.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated GeForce RTX 3070 () - 13th Gen Intel(R) Core(TM) i7-13700K (24 Threads)

Issue description

When using Input.get_vector, if any of the actions involved have an analog input bound (for example a joystick axis), the negative_x input will not have a strength of 1 when used with a non-analog input (such as a keyboard key). Instead, the strength will depend on the deadzone configured in the action.

If the deadzone param of Input.get_vector is set to 1, the negative_x axis will stop working altogether.

Removing the analog input from all the actions makes the issue go away.

Steps to reproduce

In any blank project, add the following code to an empty script and attach it:

func _process(delta: float) -> void:
    var input := Input.get_vector("ui_left", "ui_right", "ui_down", "ui_up")
    print(input.length())

Run the scene and notice that, when pressing the left key, the vector strength is less than 1. For the default deadzone of 0.5, it will read around 0.81. Right, Up and Down are not affected.

Minimal reproduction project (MRP)

N/A

JoNax97 commented 1 week ago

I believe this is related to https://github.com/godotengine/godot/issues/90515, even though the symptom described is not exactly the same.

AThousandShips commented 1 week ago

See also:

JoNax97 commented 1 week ago

I've just tested the issue in 4.2 dev6, and it is slightly different there. It reads incorrectly if you press the left key first, but after you press any other axis, pressing left again will read 1 as expected.