How to separate input event between map (TileMap) and movable units (Area2D)?

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

Hey folks,

What happens right now…
I have a conundrum about how to approach movable units on a TileMap. I’m using Area2D for the units, and this offers the input_event signal to check when a unit has been clicked. This works fine. In order to move units, I need to select a tile on the TileMap, which I can do with _input(event).

However, clicking on a unit (Area2D), also triggers an event on the TileMap. What’s more, the TileMap event is fired first due to the order in which events and signals work. Whenever I click on a unit, the tile beneath it receives an event too, and ahead of the unit.

What I want to achieve…

Ideally, I want the unit to receive its event/signal first and the event to propagate no further. Is Area2D the wrong node to be using for a unit that I want to be selectable? Can you recommend another approach?

Any help would be appreciated. Thanks! :slight_smile:

Did you manage to solve your problem?

nurzhan.izbassov | 2019-05-07 16:10

I have the same problem and haven’t found an elegant answer yet.

kinmaster3 | 2020-11-07 16:15