0 votes

Hi all, I have a tilemap where my character moves about and I have various HUD buttons etc.

Currently I click on a hud button but as the HUD sits above the tilemap, the character moves to where the button is.

How can I stop this happening so that the character only moves if I clicked on the Tilemap and nothing else?

Thanks so much

(here is my move code)

func _input(event):
if event.is_action_pressed('click'):
    if globals.activity == "walk":
        target_position = get_global_mouse_position()
        _change_state(STATES.FOLLOW)
in Engine by (810 points)

1 Answer

0 votes
Best answer

You should use _unhandled_input() for your game objects, so that your GUI may consume events first.

Read this for details: https://docs.godotengine.org/en/latest/tutorials/inputs/inputevent.html

by (18,221 points)
selected by

Thank you so much. Totally makes sense and is now working

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories