I use Input.is_action_just_pressed() a lot in my player operations.
Now, I want to prevent the player from acting in some situations, like during a conversation or when the inventory is open.
But according to the documentation, the traditional solution seems unable to stop it.
Note: Input’s methods reflect the global input state and are not affected by Control.accept_event or Viewport.set_input_as_handled, as those methods only deal with the way input is propagated in the SceneTree.
How should I solve this? Do I have to refactor all my existing code to _unhandled_input()?
For Input.is_action_just_pressed you have to handle it in your own code by having a check, you don’t need to use _unhandled_input (and you shouldn’t use Input.is_action_just_pressed in the _input or _gui_input methods anyway), unless you are using input events, then you can handle things with other methods, including having a node that captures all input that’s at the top of the tree and gets processed first, eating up all the events
A method I’ve used before is to have a separate node as a child of the player, which handles inputs - the main player script then reads the inputs from there. Then, whenever I don’t want the player to have control, I just pause that one node.