24 lines
779 B
GDScript
24 lines
779 B
GDScript
extends Camera3D
|
|
|
|
signal wall_hit(wall_id, position, cutter)
|
|
|
|
func shoot_ray() -> Dictionary:
|
|
var mouse_position = get_viewport().get_mouse_position()
|
|
var ray_length = 1000
|
|
var from = project_ray_origin(mouse_position)
|
|
var to = from + project_ray_normal(mouse_position) * ray_length
|
|
var space = get_world_3d().direct_space_state
|
|
var ray_query = PhysicsRayQueryParameters3D.new()
|
|
ray_query.from = from
|
|
ray_query.to = to
|
|
var raycast_result = space.intersect_ray(ray_query)
|
|
|
|
return raycast_result
|
|
|
|
func _input(event: InputEvent) -> void:
|
|
if event.is_action_pressed("left_click"):
|
|
var query_result = shoot_ray()
|
|
if query_result:
|
|
var cutter: PackedVector2Array = Cutter.circleCutter()
|
|
wall_hit.emit(query_result["collider_id"], query_result["position"], cutter)
|