mirror of
https://github.com/Steffo99/pineapple-surf.git
synced 2024-11-22 15:54:20 +00:00
26 lines
485 B
GDScript3
26 lines
485 B
GDScript3
|
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()
|
||
|
|