mirror of
https://github.com/Steffo99/pineapple-surf.git
synced 2024-11-24 08:44:18 +00:00
25 lines
506 B
GDScript
25 lines
506 B
GDScript
extends Node3D
|
|
|
|
|
|
@export_node_path(RigidBody3D) var target_path: NodePath
|
|
@onready var sound: AudioStreamPlayer3D = $CollectSound
|
|
var is_collected := false
|
|
|
|
@onready var target: RigidBody3D = get_node(target_path)
|
|
|
|
signal collected()
|
|
|
|
|
|
func collect():
|
|
is_collected = true
|
|
target.visible = false
|
|
sound.play()
|
|
emit_signal("collected")
|
|
await get_tree().create_timer(1).timeout
|
|
target.queue_free()
|
|
|
|
|
|
func _on_collect_area_body_entered(body: Node3D):
|
|
if body is Player and not is_collected:
|
|
collect()
|
|
|