Browse Source

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().
Mark Wilson 1 year ago
parent
commit
41e70db8b1
1 changed files with 1 additions and 1 deletions
  1. 1 1
      core/input/input.cpp

+ 1 - 1
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);
 }