From 41e70db8b1e96af275885cf73d2134ceb3150dba Mon Sep 17 00:00:00 2001 From: Mark Wilson <23439518+wlsnmrk@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:17:40 -0400 Subject: [PATCH] Fix action_press() by clamping strength to 0, 1 Changed Input.action_press() treatment of strength parameter to match behavior of InputEventAction and documentation, by clamping between 0 and 1. Fixes Input.get_action_strength() returning values over 1 when large values are passed to Input.action_press(). --- core/input/input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/input/input.cpp b/core/input/input.cpp index 3de0ed39ec77..c24a59203fd7 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -894,7 +894,7 @@ void Input::action_press(const StringName &p_action, float p_strength) { } action_state.exact = true; action_state.api_pressed = true; - action_state.api_strength = p_strength; + action_state.api_strength = CLAMP(p_strength, 0.0f, 1.0f); _update_action_cache(p_action, action_state); }