buckshotroulette-decomp/MouseRaycast.gd

18 lines
437 B
GDScript3
Raw Normal View History

2024-01-20 12:17:43 +00:00
class_name MouseRaycast extends Camera3D
var mouse = Vector2()
var result = null
func _input(event):
if event is InputEventMouse:
mouse = event.position
func _process(delta):
get_selection()
func get_selection():
var worldspace = get_world_3d().direct_space_state
var start = project_ray_origin(mouse)
var end = project_position(mouse, 20000)
result = worldspace.intersect_ray(PhysicsRayQueryParameters3D.create(start, end))