Topic was automatically imported from the old Question2Answer platform.
Asked By
jujumumu
From my understanding you can use input events or Input.is_action_pressed for input. I use the second one since it is more simple. But when I type in a line edit the input activates when I don’t want it to. How could I fix this? Is using the first method better and more efficient? If so please write the code for it.
Have you seen this answer from KidsCanCode? I think he lays out a good answer which could help you.
This problem is precisely why this input difference exists. Using the Input singleton feels easier because it lets you ignore everything else. That means it runs whatever else is on screen. So in your case, you would need to create a boolean variable to add an if in_line_edit to prevent your input code from running, which is probably fine in small games, but can become a nightmare to handle yourself in larger games.
Handling input properly can be a whole subject on its own. This is why input propagation exists with the _input, _gui_input and _unhandled_input methods. They are more complicated to use, but they handle these cases for you.
Yet, Input still exists because there are cases where it remains more convenient, provided you understand how to deal with GUI.
How could I use _input(event) for my movement input since I use _physics_process(delta) with Input.isactionpressed for input.
jujumumu | 2019-09-02 15:00
Either detect when your UI is open and do an if with a boolean variable,
or implement _unhandled_input and store input in variables so you can use it in _physics_process.
You can also pause your game using the pause system: Pausing games — Godot Engine (3.1) documentation in English