IntersectPoint not working for me (2D)

Godot Version

Godot 4.3 Stable Mono

Question

Hello, I try to cast IntersectPoint by this code:

private Node RaycastCheckForCard()
{
	var spaceState = GetWorld2D().DirectSpaceState;

	var parameters = new PhysicsPointQueryParameters2D();
	parameters.Position = GetGlobalMousePosition();
	parameters.CollideWithAreas = true;
	parameters.CollisionMask = 1;

	var result = spaceState.IntersectPoint(parameters);
	GD.Print(result);
	return null; // for example null
}

But, GD.Print(result) print [] result. This is always printed, even when I click on Area2D with CollisionShape2D. Collision Mask and Collision Layer setted at 1. I don’t know why this is not working.
Thanks for any help!

Looks like by default intersect_with_point has the parameter collide_with_areas=false.

Try passing all parameters with this set to true to intersect with an Area2D.

Hello, @arkaein!
I already writed it:

parameters.CollideWithAreas = true;

I succesful found the solution! So, I read the docs and drew attention to CanvasInstanceId property. So, default this property setted to 0. I get my CanvasLayer by GetCanvasLayerNode().GetInstanceId() and output this by GD.Print(). Then I added the following code to parameters:

parameters.CanvasInstanceId = 25786582282;

Where 25786582282 is my CanvasInstanceId. By specifying this, everything now works correctly.