0 votes

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);


Godot version v3.4.stable.mono.official [206ba70f4]
in Engine by (15 points)

1 Answer

0 votes
Best answer

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 GUIInput method along with mousefilter can set up elastic hierarchy of input consumption

by (7,925 points)
selected by

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

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 Frequently asked questions and 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 [email protected] with your username.