From 9221e6a46660c6e59a4efcdccb60f0b7a85f0df3 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Tue, 16 Jul 2024 07:11:27 +0100 Subject: [PATCH] Fix physics tick count in `Input.action_press` and `Input.action_release` The physics tick count was not yet updated there. --- main/input_default.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main/input_default.cpp b/main/input_default.cpp index 5cf68caa816..24505577c03 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -646,7 +646,8 @@ void InputDefault::action_press(const StringName &p_action, float p_strength) { // Create or retrieve existing action. Action &action = action_state[p_action]; - action.pressed_physics_frame = Engine::get_singleton()->get_physics_frames(); + // As input may come in part way through a physics tick, the earliest we can react to it is the next physics tick. + action.pressed_physics_frame = Engine::get_singleton()->get_physics_frames() + 1; action.pressed_idle_frame = Engine::get_singleton()->get_idle_frames(); action.pressed = true; action.exact = true; @@ -658,7 +659,8 @@ void InputDefault::action_release(const StringName &p_action) { // Create or retrieve existing action. Action &action = action_state[p_action]; - action.released_physics_frame = Engine::get_singleton()->get_physics_frames(); + // As input may come in part way through a physics tick, the earliest we can react to it is the next physics tick. + action.released_physics_frame = Engine::get_singleton()->get_physics_frames() + 1; action.released_idle_frame = Engine::get_singleton()->get_idle_frames(); action.pressed = false; action.exact = true;