Skip to content

Input.action_press() accepts and sets action state to out-of-bounds strength values #89945

Closed
@wlsnmrk

Description

@wlsnmrk

Tested versions

Reproducible in v4.1.1.stable.mono.official [bd6af8e], v4.2.1.stable.mono.official [b09f793], v4.3.dev.mono.custom_build [7d151c8]

System information

Godot v4.2.1.stable.mono - Windows 10.0.22631

Issue description

Input.action_press() should only accept values for its strength parameter between 0 and 1, and likewise Input.get_action_strength() should only return values between 0 and 1. The analogous InputEventAction.strength property is correctly clamped between 0 and 1, and cannot be set outside that range.

However, Input.action_press() does not bounds-check the strength parameter, and if passed a value greater than 1, sets the action state to an out-of-bounds value, causing Input.get_action_strength() to return the same out-of-bounds value. In v4.1, values less than 0 are also accepted into action state.


Illustrative screenshot of the MRP (running in v4.2), which shows the correct behavior of the InputEventAction.strength property as well as the bug in Input.action_press():
Screenshot 2024-03-27 114746

Steps to reproduce

See attached MRP, or do:

Input.action_press("test_action", 2.0)
print(str(Input.get_action_strength("test_action"))

For v4.1, Input.action_press("test_action", -1.0) will also produce incorrect output.

Minimal reproduction project (MRP)

ActionPressStrengthMRP.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions