Created
April 2, 2024 12:35
-
-
Save NovemberDev/0498989b5fcb01461606279e7109b128 to your computer and use it in GitHub Desktop.
Raycast from mouse position in 3D space in Godot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func raycast(camera: Camera3D): | |
var rayOrigin = camera.project_ray_origin(get_viewport().get_mouse_position()) | |
var query = PhysicsRayQueryParameters3D.create(rayOrigin, rayOrigin + camera.project_ray_normal(get_viewport().get_mouse_position()) * 200); | |
return camera.get_world_3d().direct_space_state.intersect_ray(query) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment