You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
500 B
18 lines
500 B
extends Node3D
|
|
@onready var ray_cast: RayCast3D = $RayCast3D
|
|
|
|
const Interactable = preload("uid://d1pa8ssvmxbn")
|
|
|
|
@export var max_distance: float = 100
|
|
|
|
func _ready() -> void:
|
|
ray_cast.target_position = Vector3(0,0,-max_distance)
|
|
|
|
func _input(event: InputEvent) -> void:
|
|
if event.is_action_pressed("interact"):
|
|
if ray_cast.is_colliding():
|
|
var collider = ray_cast.get_collider()
|
|
if collider.get_script() == Interactable:
|
|
var interactable: Interactable = collider
|
|
interactable.hit()
|