From 2b7c1028cc43ccf15674108b01bc0f16b8b89cca Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 16 Feb 2024 22:59:23 +0100 Subject: [PATCH] Added soul collection sound --- client/item/soul/Soul.gd | 36 ++++++++++++++++++++---------------- client/item/soul/Soul.tscn | 9 ++++++++- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/client/item/soul/Soul.gd b/client/item/soul/Soul.gd index 73539bc..179a70f 100644 --- a/client/item/soul/Soul.gd +++ b/client/item/soul/Soul.gd @@ -8,7 +8,7 @@ var attractor: GPUParticlesAttractor3D var light: Light3D var sprite: Sprite3D var area: Area3D - +var sound: AudioStreamPlayer3D var collected_by: Player func _ready(): @@ -18,6 +18,7 @@ func _ready(): sprite = %Sprite area = %Area attractor = %Attractor + sound = %Sound func _process(delta): if !collected_by: @@ -26,18 +27,21 @@ func _process(delta): global_position = Math.damp(global_position, Global.player.global_position + Vector3.UP, 1.0 * delta) func on_body_entered(body: Node3D): - if body is Player: - collected_by = body - attractor.visible = false - area.set_deferred("monitoring", false) - particles.process_material.attractor_interaction_enabled = true - - var tween = get_tree().create_tween() - tween.parallel().tween_property(particles, "amount_ratio", 0, tween_duration) - # tween.parallel().tween_property(trails, "amount_ratio", 0, tween_duration) - tween.parallel().tween_property(light, "light_energy", 0, tween_duration) - tween.parallel().tween_property(sprite, "scale", Vector3.ZERO, tween_duration) - tween.parallel().tween_property(sprite, "material_override:albedo_color", Color(0, 0, 0, 0), tween_duration) - await tween.finished - await get_tree().create_timer(2.0).timeout - queue_free() + if not body is Player: + return + + collected_by = body + attractor.visible = false + area.set_deferred("monitoring", false) + particles.process_material.attractor_interaction_enabled = true + sound.play() + + var tween = get_tree().create_tween() + tween.parallel().tween_property(particles, "amount_ratio", 0, tween_duration) + # tween.parallel().tween_property(trails, "amount_ratio", 0, tween_duration) + tween.parallel().tween_property(light, "light_energy", 0, tween_duration) + tween.parallel().tween_property(sprite, "scale", Vector3.ZERO, tween_duration) + tween.parallel().tween_property(sprite, "material_override:albedo_color", Color(0, 0, 0, 0), tween_duration) + await tween.finished + await get_tree().create_timer(2.0).timeout + queue_free() diff --git a/client/item/soul/Soul.tscn b/client/item/soul/Soul.tscn index 603e77f..b987fc4 100644 --- a/client/item/soul/Soul.tscn +++ b/client/item/soul/Soul.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=13 format=3 uid="uid://dl4vcp04t8iyr"] +[gd_scene load_steps=14 format=3 uid="uid://dl4vcp04t8iyr"] [ext_resource type="Texture2D" uid="uid://cdoxs0s8xh1b3" path="res://particle/FadeOut.tres" id="1_dd0n2"] [ext_resource type="Texture2D" uid="uid://c3wx3cgn8x62m" path="res://assets/particles/particles-single.png" id="1_hhudy"] [ext_resource type="Script" path="res://item/soul/Soul.gd" id="1_mm7cb"] [ext_resource type="Texture2D" uid="uid://cfkwtmj6tc3wa" path="res://item/soul/color_ramp.tres" id="3_ibw0j"] +[ext_resource type="AudioStream" uid="uid://l6d76tn8ys5n" path="res://assets/audio/effects/Games-Video-Event-Collect-Item.wav" id="5_cxtbb"] [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_uyeuh"] lifetime_randomness = 0.15 @@ -123,4 +124,10 @@ monitorable = false [node name="SphereShape" type="CollisionShape3D" parent="Area"] shape = SubResource("SphereShape3D_rytrf") +[node name="Sound" type="AudioStreamPlayer3D" parent="."] +unique_name_in_owner = true +stream = ExtResource("5_cxtbb") +max_distance = 20.0 +bus = &"Effects" + [connection signal="body_entered" from="Area" to="." method="on_body_entered"]