diff options
author | Ricardo Buring <ricardo.buring@gmail.com> | 2024-07-16 00:26:01 +0200 |
---|---|---|
committer | Ricardo Buring <ricardo.buring@gmail.com> | 2024-07-16 00:31:44 +0200 |
commit | b41ec93d633530a80ca6f9f55b41da0e0bcd2acb (patch) | |
tree | 2c7e0f9649084cf3c8fd5c01649a52d2acfb97c3 /core | |
parent | 97b8ad1af0f2b4a216f6f1263bef4fbc69e56c7b (diff) | |
download | redot-engine-b41ec93d633530a80ca6f9f55b41da0e0bcd2acb.tar.gz |
Fix physics tick count in Input.action_press and Input.action_release
The physics tick count was not yet updated there.
Diffstat (limited to 'core')
-rw-r--r-- | core/input/input.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/input/input.cpp b/core/input/input.cpp index ec0303df06..8d3fb953ed 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -890,8 +890,9 @@ void Input::action_press(const StringName &p_action, float p_strength) { // Create or retrieve existing action. ActionState &action_state = action_states[p_action]; + // As input may come in part way through a physics tick, the earliest we can react to it is the next physics tick. if (!action_state.cache.pressed) { - action_state.pressed_physics_frame = Engine::get_singleton()->get_physics_frames(); + action_state.pressed_physics_frame = Engine::get_singleton()->get_physics_frames() + 1; action_state.pressed_process_frame = Engine::get_singleton()->get_process_frames(); } action_state.exact = true; @@ -908,7 +909,8 @@ void Input::action_release(const StringName &p_action) { action_state.cache.pressed = 0; action_state.cache.strength = 0.0; action_state.cache.raw_strength = 0.0; - action_state.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_state.released_physics_frame = Engine::get_singleton()->get_physics_frames() + 1; action_state.released_process_frame = Engine::get_singleton()->get_process_frames(); action_state.device_states.clear(); action_state.exact = true; |