Custom 3D cursor causes game to crash when I move it above the game window in screen space. The following code block handles everything to do with the 3D cursor. How would I allow the cursor to be placed outside of the game window?

func look_at_cursor():
	var drop_plane = Plane(Vector3(0, 1, 0), global_transform.origin.y)
	var mouse_pos = get_viewport().get_mouse_position()
	var from = camera.project_ray_origin(mouse_pos)
	var to = from + camera.project_ray_normal(mouse_pos) * 1000
	var cursor_pos = drop_plane.intersects_ray(from, to)
	cursor.global_transform.origin = cursor_pos + Vector3(0, 1, 0)
	look_at(cursor_pos, Vector3.UP)

Not sure if this is the solution you wanted but you can use this for confine the mouse inside the window:

Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

And (for testing) setting aswell a shortcut for make visible again:

func _unhandled_input(event: InputEvent) -> void:
   if event.is_action_pressed("ui_cancel"):
     Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)     

I think your code make the look_at point to the infinite and crash.

    fatalox Isn't MOUSE_MODE_CAPTURED for FPS style games? Sorry for not specifying, this is a top down shooter.

      Lousifr I think MOUSE_MODE_CAPTURED it is a pretty standard for every game.
      For having a mouse cursor you should make your custom one inside godot, with relative code for control it.
      You can testing even with MOUSE_MODE_CONFINED
      (this will make standard cursor visible but not fixed at center of the window)

        fatalox I just tried both CAPTURED and CONFINED,
        CAPTURED kept the cursor locked to the center of the screen, not allowing the player to rotate.
        CONFINED still crashed when I go to far upward in screen coordinates, and it didn't hide the cursor.

        In order for this to work as I want, I think I need to be able to extract the screen coordinates, even when they go negative in terms of the window coordinates.