If the projection is changed from “Perspective” to “Orthogonal,” the current code would not work for picking the turret position. After some digging around I find that if the code is changed to:
var mouse_position: Vector2 = get_viewport().get_mouse_position()
ray_cast_3d.global_position = project_ray_origin(mouse_position)
ray_cast_3d.target_position = ray_cast_3d.global_position + project_local_ray_normal(mouse_position) * 30000.0
ray_cast_3d.force_raycast_update()
then it works. However there’s still an offset along the z axis for some reason. This is more apparent if the multiplier is changed to 1000. Am I going about this the right way? Is there a way to get rid of the offset for good?
P.S. If you keep the current camera settings, later on in the course you’ll find that the trees near the edge of the screen will look distorted. This can be remedied by lowering the FOV or using Keep Width instead of Keep Height.