1
Fork 0
mirror of https://github.com/Steffo99/pineapple-surf.git synced 2024-11-22 15:54:20 +00:00
pineapple-surf/island/CollectibleByPlayer.gd

26 lines
485 B
GDScript3
Raw Normal View History

2023-01-08 20:27:26 +00:00
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:
collect()