I put together a quick example, which might could help you.
Here you can see my scene hierarchy:
And I have the following script on my Camera:
var ray = RayCast.new()
ray.enabled = true
var distance_from_camera = far
if event is InputEventMouseButton:
var from = project_ray_origin(event.position);
var to = from + project_ray_normal(event.position) * distance_from_camera;
ray.cast_to = to-global_transform.origin
if (event is InputEventMouseButton):
if (event.pressed == false and event.button_index == 1):
var raypoint = ray.get_collision_point()
return print("raypoint:", raypoint)
Is this similar to your use case?