mirror of
https://github.com/Steffo99/pineapple-surf.git
synced 2024-11-21 23:34:21 +00:00
Refactor SplashController
This commit is contained in:
parent
0322c74bac
commit
56b59f42d3
3 changed files with 31 additions and 14 deletions
|
@ -1,12 +1,11 @@
|
|||
[gd_scene load_steps=17 format=3 uid="uid://b5i1sqd88wlle"]
|
||||
[gd_scene load_steps=16 format=3 uid="uid://b5i1sqd88wlle"]
|
||||
|
||||
[ext_resource type="Script" path="res://player/Player.gd" id="1_rujcr"]
|
||||
[ext_resource type="Script" path="res://player/Head.gd" id="2_ohlgu"]
|
||||
[ext_resource type="Script" path="res://player/OnHand.gd" id="3_3rcjl"]
|
||||
[ext_resource type="Theme" uid="uid://c5a1nyqumj46j" path="res://menu/menu_theme.tres" id="4_d7ru6"]
|
||||
[ext_resource type="Shader" path="res://player/crosshair.gdshader" id="4_dut1p"]
|
||||
[ext_resource type="Script" path="res://player/SplashController.gd" id="5_wnbq8"]
|
||||
[ext_resource type="AudioStream" uid="uid://xretxahxbqdr" path="res://assets/splash.ogg" id="6_xi537"]
|
||||
[ext_resource type="PackedScene" uid="uid://dc147tdie7oem" path="res://player/SplashController.tscn" id="6_hf66s"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_aqp8x"]
|
||||
metallic_specular = 0.0
|
||||
|
@ -262,8 +261,5 @@ metadata/_edit_lock_ = true
|
|||
|
||||
[node name="RigidDynamicBody3D" type="RigidBody3D" parent="."]
|
||||
|
||||
[node name="SplashController" type="Node" parent="."]
|
||||
script = ExtResource("5_wnbq8")
|
||||
|
||||
[node name="SplashSound" type="AudioStreamPlayer" parent="SplashController"]
|
||||
stream = ExtResource("6_xi537")
|
||||
[node name="SplashController" parent="." instance=ExtResource("6_hf66s")]
|
||||
target_path = NodePath("..")
|
||||
|
|
|
@ -1,13 +1,24 @@
|
|||
extends Node
|
||||
|
||||
|
||||
@onready var player: Node3D = $".."
|
||||
@onready var spawn_point: Vector3 = player.position
|
||||
@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
|
||||
@onready var splash_sound: AudioStreamPlayer = $SplashSound
|
||||
|
||||
|
||||
signal splashed()
|
||||
|
||||
|
||||
func splash():
|
||||
splash_sound.play()
|
||||
target.position = spawn_point
|
||||
target.velocity = Vector3.ZERO
|
||||
emit_signal("splashed")
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
if player.position.y < 0:
|
||||
splash_sound.play()
|
||||
player.position = spawn_point
|
||||
player.velocity = Vector3.ZERO
|
||||
if target.position.y < splash_threshold:
|
||||
splash()
|
||||
|
|
10
player/SplashController.tscn
Normal file
10
player/SplashController.tscn
Normal file
|
@ -0,0 +1,10 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://dc147tdie7oem"]
|
||||
|
||||
[ext_resource type="Script" path="res://player/SplashController.gd" id="1_m4yh2"]
|
||||
[ext_resource type="AudioStream" uid="uid://xretxahxbqdr" path="res://assets/splash.ogg" id="2_esng3"]
|
||||
|
||||
[node name="SplashController" type="Node"]
|
||||
script = ExtResource("1_m4yh2")
|
||||
|
||||
[node name="SplashSound" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource("2_esng3")
|
Loading…
Reference in a new issue