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!
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.