Skip to content

Commit

Permalink
Merge pull request godotengine#94421 from lawnjelly/fix_action_press_…
Browse files Browse the repository at this point in the history
…tick

[3.x] Fix physics tick count in `Input.action_press` and `Input.action_rele…
  • Loading branch information
lawnjelly authored Jul 16, 2024
2 parents ff77fe8 + 9221e6a commit 49339fd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions main/input_default.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 49339fd

Please sign in to comment.