extends AudioStreamPlayer3D @export var threshold: float = 1.5 @export var targetElement: Node3D var currentLocation: Vector3 var distance: float # Called when the node enters the scene tree for the first time. func _ready() -> void: currentLocation = targetElement.global_position distance = threshold # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: var positionDistance = targetElement.global_position.distance_to(currentLocation) currentLocation = targetElement.global_position distance = distance - positionDistance if (distance > 0): return distance = threshold play()