2024-01-20 12:17:43 +00:00
|
|
|
class_name MouseRaycast extends Camera3D
|
|
|
|
|
2024-04-05 10:52:30 +01:00
|
|
|
@export var checkingOverride : bool
|
|
|
|
@export var cursor : CursorManager
|
2024-01-20 12:17:43 +00:00
|
|
|
var mouse = Vector2()
|
|
|
|
var result = null
|
|
|
|
|
2024-04-05 10:52:30 +01:00
|
|
|
var controller_overriding = false
|
|
|
|
|
2024-01-20 12:17:43 +00:00
|
|
|
func _input(event):
|
|
|
|
if event is InputEventMouse:
|
2024-04-05 10:52:30 +01:00
|
|
|
if(!controller_overriding): mouse = event.position
|
2024-01-20 12:17:43 +00:00
|
|
|
|
|
|
|
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))
|
2024-04-05 10:52:30 +01:00
|
|
|
|
|
|
|
func GetRaycastOverride(pos_override : Vector2):
|
|
|
|
controller_overriding = true
|
|
|
|
mouse = pos_override
|
|
|
|
|
|
|
|
func StopRaycastOverride():
|
|
|
|
controller_overriding = false
|