I want to do the controls like in Dota. There, when you click on any terrain, a point appears where the character needs to go. How to make this system? I am trying to do this with rays but cannot find the end position:
var space_state = get_world().direct_space_state
if Input.is_action_pressed("LefftClick"):
_to_ray_cast = translation
_to_ray_cast.y -= 15
ray_cast = space_state.intersect_ray(
translation, _to_ray_cast)
print(ray_cast)
How to do it ? The screen size may change.

Example. I hover over the red dot and click. I need the exact cardinals in the world where I clicked. There's a wall next to these coordinates