How can I disable the input when clicking button?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By burak

My game is based click movement. When you click a place, the game character goes to the clicked position. Then I added some buttons like “pause game”, “turn of sound”, “settings menu”. When I click the buttons, the game character goes to the position. How can I disable the movement when I click the buttons?

click button

You can see the picture. I don’t want the movement when clicking the button.

:bust_in_silhouette: Reply From: kidscancode

Your code should be set up so that GUI objects consume the events first. When Godot processes inputs, they pass from the Viewport through a series of methods in priority order.

This will happen automatically if you use _unhandled_input() for your character movement, rather than _input(), which has a higher priority than GUI input.

See InputEvent for more details, including a useful flowchart of input processing.

I changed to _unhandled_input() and the problem solved.

burak | 2019-08-31 13:44