Ordering of _InputEvent calls of Area2D

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

I have two sprites and I want to detect that is one of them is clicked (setting Material to outline sprite). If a user is miss clicked out or clicked on another sprite the Material sets null for other sprites.

My vision is to create Area2D with nested two Area2D. But when I clicked on nested sprite a _InputEvent called randomly. I assumed that the first call for GlobalArea and next calls for nested Area2Ds.


And a script for each Area2D:

using Godot;
using System;

public class Area : Godot.Area2D

    public override void _InputEvent(Godot.Object viewport, InputEvent @event, int shapeIdx) {
        if(@event.IsPressed()) {
            GD.Print("Clicled " + Name);


:bust_in_silhouette: Reply From: Inces

Hey, I don’t think there is any order of overlapping areas taking Input, they propably do it simultanously and print order is just float inaccuracy. If You want to have order use Control nodes (texture rect is basically the same as sprite). Their GUI_Input method along with mouse_filter can set up elastic hierarchy of input consumption

Yes, the Control with TextureRect works as it should. Thank you!

_42 | 2021-12-22 06:50