1
Fork 0
mirror of https://github.com/Steffo99/pineapple-surf.git synced 2024-11-29 03:04:17 +00:00
pineapple-surf/player/SplashController.gd

25 lines
516 B
GDScript3
Raw Normal View History

2023-01-07 18:23:07 +00:00
extends Node
2023-01-08 20:46:19 +00:00
@export_node_path(CharacterBody3D) var target_path: NodePath
@export var splash_threshold: float = 0.0
@onready var target: CharacterBody3D = get_node(target_path)
@onready var spawn_point: Vector3 = target.position
2023-01-07 18:23:07 +00:00
@onready var splash_sound: AudioStreamPlayer = $SplashSound
2023-01-08 20:46:19 +00:00
signal splashed()
func splash():
splash_sound.play()
target.position = spawn_point
target.velocity = Vector3.ZERO
emit_signal("splashed")
2023-01-07 18:23:07 +00:00
func _process(_delta):
2023-01-08 20:46:19 +00:00
if target.position.y < splash_threshold:
splash()