Hello, I have Area2Ds in my scene that get highlighted when I hover over them, and a HUD that covers the screen. When I show the HUD I disable the highlights, and when I hide the HUD I want them to appear again, but MouseEntered doesn't get fired on the areas this case. I have to move my mouse outside of the area and back in for the highlight to appear again.

I dunno how to find which area my mouse is on top of so I can highlight it when I hide the HUD. They're not rectangles, so I can't just use a simple Rect2.HasPoint().

This describes the same problem:

(I haven't tried the first answer, it sounds a bit hacky and I would rather get this to work...)

public override void _PhysicsProcess(double delta)
{
	PhysicsPointQueryParameters2D _params = new PhysicsPointQueryParameters2D() {
		Position = GetGlobalMousePosition(),
		CollideWithAreas = true,
		CollideWithBodies = true
	};
	var hits = GetWorld2D().DirectSpaceState.IntersectPoint(_params, 5);
	GD.Print(hits);
}

I'm not sure where it's supposed to go, I tried adding it both to the Area2Ds and to the root node, either way I get an empty array.

  • xyz replied to this.

    housatic Areas emit input_event signals that cover wider variety of mouse events beside just entered/exited so you may be able to solve this by listening to that signal.

    Btw what type of colliders are you using for the areas?

      xyz Good idea, I'll take a look at the other signals. I'm using CollisionPolygon2D.

      • xyz replied to this.

        housatic According to docs, IntersectPoint wont work with CollisionPolygon2D or ConcavePolygonShape2D shapes. Try replacing them with some other shapes.

          xyz Ah, once again I didn't read note. It says "in Segments build mode" though, mine are all Solids?

          I'm creating the hitboxes/polygons dynamically from sprites, so I do kinda need the CollisionPolygon2D unless there's an alternative.

          • xyz replied to this.

            housatic Still, test the whole thing with simple box colliders to check if shapes are the cause of the problem.