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()
|