From 89d730f0aed3b9ab23563aa7422e3954cbd448ab Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 16 Feb 2024 15:30:29 +0100 Subject: [PATCH] Added voice audio --- client/player/Player.tscn | 26 +++++++++++-------- client/player/{audio => footsteps}/Foot.gd | 0 .../FootstepsComponent.gd} | 4 +-- .../FootstepsComponent.tscn} | 6 ++--- client/player/voice/VoiceComponent.gd | 19 ++++++++++++++ client/player/voice/VoiceComponent.tscn | 10 +++++++ client/skill/SkillInstance.gd | 2 ++ client/skill/slash/slash.gd | 3 +++ client/skill/slash/slash.tscn | 18 +++---------- client/skill/slash/slash_voice.tres | 10 +++++++ client/skill/spin/spin.gd | 3 +++ client/skill/spin/spin.tscn | 21 +++------------ client/skill/spin/spin_voice.tres | 13 ++++++++++ 13 files changed, 86 insertions(+), 49 deletions(-) rename client/player/{audio => footsteps}/Foot.gd (100%) rename client/player/{audio/AudioComponent.gd => footsteps/FootstepsComponent.gd} (96%) rename client/player/{audio/AudioComponent.tscn => footsteps/FootstepsComponent.tscn} (61%) create mode 100644 client/player/voice/VoiceComponent.gd create mode 100644 client/player/voice/VoiceComponent.tscn create mode 100644 client/skill/slash/slash_voice.tres create mode 100644 client/skill/spin/spin_voice.tres diff --git a/client/player/Player.tscn b/client/player/Player.tscn index 77f1968..af56087 100644 --- a/client/player/Player.tscn +++ b/client/player/Player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=30 format=3 uid="uid://2lcnu3dy54lx"] +[gd_scene load_steps=31 format=3 uid="uid://2lcnu3dy54lx"] [ext_resource type="Script" path="res://player/Player.gd" id="1_8gebs"] [ext_resource type="PackedScene" uid="uid://c8j7t4yg7anb0" path="res://assets/female/Female.blend" id="2_8nah6"] @@ -12,6 +12,7 @@ [ext_resource type="PackedScene" uid="uid://6jpnl6c4fdvo" path="res://player/hud/HUDComponent.tscn" id="7_fwgtd"] [ext_resource type="PackedScene" uid="uid://qecdmrg6mbws" path="res://assets/swords/heirloom/Heirloom.blend" id="7_u8433"] [ext_resource type="PackedScene" uid="uid://x102pryt2s5a" path="res://player/movement/MovementComponent.tscn" id="8_25qd0"] +[ext_resource type="PackedScene" uid="uid://clnfp813k7lep" path="res://player/footsteps/FootstepsComponent.tscn" id="8_xklbo"] [ext_resource type="PackedScene" uid="uid://d0onbq0ad1ap4" path="res://player/rotation/RotationComponent.tscn" id="9_agxqu"] [ext_resource type="PackedScene" uid="uid://bivxnxwi863o0" path="res://player/animation/AnimationComponent.tscn" id="10_bcaeg"] [ext_resource type="AnimationLibrary" uid="uid://d4n0puibh4hyt" path="res://assets/animations/human.blend" id="11_d0e6r"] @@ -21,12 +22,12 @@ [ext_resource type="AudioStream" uid="uid://bsc8b4ltoiflu" path="res://assets/audio/footsteps/Footsteps-Human-Dirt-03.wav" id="15_1rjwu"] [ext_resource type="AudioStream" uid="uid://b5xq4cfmo02vw" path="res://assets/audio/footsteps/Footsteps-Human-Dirt-04.wav" id="16_d8yn0"] [ext_resource type="AudioStream" uid="uid://cpldevudwvnkt" path="res://assets/audio/footsteps/Footsteps-Human-Dirt-05.wav" id="17_74v1j"] -[ext_resource type="PackedScene" uid="uid://clnfp813k7lep" path="res://player/audio/AudioComponent.tscn" id="17_ovrf7"] [ext_resource type="AudioStream" uid="uid://biyotdu77a788" path="res://assets/audio/footsteps/Footsteps-Human-Dirt-06.wav" id="18_qkget"] [ext_resource type="AudioStream" uid="uid://cdywep3dxm0y3" path="res://assets/audio/footsteps/Footsteps-Human-Dirt-07.wav" id="19_vvmo0"] [ext_resource type="AudioStream" uid="uid://bp8pka7qhcetq" path="res://assets/audio/footsteps/Footsteps-Human-Dirt-08.wav" id="20_srjtb"] [ext_resource type="AudioStream" uid="uid://bgdodasvt7ier" path="res://assets/audio/footsteps/Footsteps-Human-Dirt-01.wav" id="21_a8ikg"] [ext_resource type="PackedScene" uid="uid://sx4ein0bju6m" path="res://player/state/StateComponent.tscn" id="28_0i0of"] +[ext_resource type="PackedScene" uid="uid://csidusk3jpq0m" path="res://player/voice/VoiceComponent.tscn" id="28_iolce"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_2f50n"] radius = 0.3 @@ -108,7 +109,15 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) strength = 15.0 radius = 2.0 -[node name="Audio" parent="." node_paths=PackedStringArray("skeleton", "movement") instance=ExtResource("17_ovrf7")] +[node name="Animation" parent="." instance=ExtResource("10_bcaeg")] + +[node name="AnimationPlayer" parent="Animation" index="0"] +root_node = NodePath("../../Model/Female") +libraries = { +"human": ExtResource("11_d0e6r") +} + +[node name="Footsteps" parent="." node_paths=PackedStringArray("skeleton", "movement") instance=ExtResource("8_xklbo")] skeleton = NodePath("../Model/Female/Armature/GeneralSkeleton") movement = NodePath("../Movement") footsteps = SubResource("AudioStreamRandomizer_4yj1k") @@ -121,18 +130,13 @@ max_value = 100.0 [node name="Rotation" parent="." node_paths=PackedStringArray("root") instance=ExtResource("9_agxqu")] root = NodePath("..") -[node name="Animation" parent="." instance=ExtResource("10_bcaeg")] - -[node name="AnimationPlayer" parent="Animation" index="0"] -root_node = NodePath("../../Model/Female") -libraries = { -"human": ExtResource("11_d0e6r") -} - [node name="Skills" parent="." instance=ExtResource("14_6idcf")] skills = Array[Resource("res://skill/Skill.gd")]([ExtResource("2_x58e1"), ExtResource("3_l76ly"), null, ExtResource("5_pnues")]) [node name="State" parent="." instance=ExtResource("28_0i0of")] +[node name="Voice" parent="." node_paths=PackedStringArray("skeleton") instance=ExtResource("28_iolce")] +skeleton = NodePath("../Model/Female/Armature/GeneralSkeleton") + [editable path="Model/Female"] [editable path="Animation"] diff --git a/client/player/audio/Foot.gd b/client/player/footsteps/Foot.gd similarity index 100% rename from client/player/audio/Foot.gd rename to client/player/footsteps/Foot.gd diff --git a/client/player/audio/AudioComponent.gd b/client/player/footsteps/FootstepsComponent.gd similarity index 96% rename from client/player/audio/AudioComponent.gd rename to client/player/footsteps/FootstepsComponent.gd index 873a472..7bcc0b0 100644 --- a/client/player/audio/AudioComponent.gd +++ b/client/player/footsteps/FootstepsComponent.gd @@ -1,5 +1,5 @@ -class_name AudioComponent -extends Node3D +class_name FootstepsComponent +extends Node @export var skeleton: Skeleton3D @export var movement: MovementComponent diff --git a/client/player/audio/AudioComponent.tscn b/client/player/footsteps/FootstepsComponent.tscn similarity index 61% rename from client/player/audio/AudioComponent.tscn rename to client/player/footsteps/FootstepsComponent.tscn index 9bb5b9d..70db607 100644 --- a/client/player/audio/AudioComponent.tscn +++ b/client/player/footsteps/FootstepsComponent.tscn @@ -1,9 +1,9 @@ [gd_scene load_steps=2 format=3 uid="uid://clnfp813k7lep"] -[ext_resource type="Script" path="res://player/audio/AudioComponent.gd" id="1_0j3jl"] +[ext_resource type="Script" path="res://player/footsteps/FootstepsComponent.gd" id="1_xjrot"] -[node name="Audio" type="Node3D"] -script = ExtResource("1_0j3jl") +[node name="Footsteps" type="Node"] +script = ExtResource("1_xjrot") [node name="LeftFoot" type="AudioStreamPlayer3D" parent="."] max_distance = 20.0 diff --git a/client/player/voice/VoiceComponent.gd b/client/player/voice/VoiceComponent.gd new file mode 100644 index 0000000..c1ebcfc --- /dev/null +++ b/client/player/voice/VoiceComponent.gd @@ -0,0 +1,19 @@ +class_name VoiceComponent +extends Node + +@export var skeleton: Skeleton3D + +var audio: AudioStreamPlayer3D + +func _ready(): + audio = $Mouth + + var attachment := BoneAttachment3D.new() + attachment.bone_name = "Head" + attachment.bone_idx = skeleton.find_bone("Head") + audio.reparent(attachment) + skeleton.add_child(attachment) + +func play(stream: AudioStream): + audio.stream = stream + audio.play() diff --git a/client/player/voice/VoiceComponent.tscn b/client/player/voice/VoiceComponent.tscn new file mode 100644 index 0000000..e891eba --- /dev/null +++ b/client/player/voice/VoiceComponent.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=2 format=3 uid="uid://csidusk3jpq0m"] + +[ext_resource type="Script" path="res://player/voice/VoiceComponent.gd" id="1_8w0p0"] + +[node name="Voice" type="Node"] +script = ExtResource("1_8w0p0") + +[node name="Mouth" type="AudioStreamPlayer3D" parent="."] +max_distance = 30.0 +bus = &"Voices" diff --git a/client/skill/SkillInstance.gd b/client/skill/SkillInstance.gd index ec707c0..4a111d3 100644 --- a/client/skill/SkillInstance.gd +++ b/client/skill/SkillInstance.gd @@ -3,10 +3,12 @@ extends Node var state: StateComponent var animation: AnimationComponent +var voice: VoiceComponent func _enter_tree(): state = get_parent().get_node("State") as StateComponent animation = get_parent().get_node("Animation") as AnimationComponent + voice = get_parent().get_node("Voice") as VoiceComponent state.current = StateComponent.State.Skill func end(): diff --git a/client/skill/slash/slash.gd b/client/skill/slash/slash.gd index b309f7e..8bed74c 100644 --- a/client/skill/slash/slash.gd +++ b/client/skill/slash/slash.gd @@ -1,6 +1,9 @@ extends AreaSkillInstance +@export var voice_audio: AudioStream + func _ready(): animation.play("human/slash", 1.7) + voice.play(voice_audio) await area_damage(0.5, 0.1, 0.2) end() \ No newline at end of file diff --git a/client/skill/slash/slash.tscn b/client/skill/slash/slash.tscn index 3322980..d5c990d 100644 --- a/client/skill/slash/slash.tscn +++ b/client/skill/slash/slash.tscn @@ -1,24 +1,12 @@ -[gd_scene load_steps=5 format=3 uid="uid://bhy50ngwxib3i"] +[gd_scene load_steps=4 format=3 uid="uid://bhy50ngwxib3i"] [ext_resource type="Script" path="res://skill/slash/slash.gd" id="1_dbiye"] +[ext_resource type="AudioStream" uid="uid://i2yim7wiuukw" path="res://skill/slash/slash_voice.tres" id="2_ldjss"] [ext_resource type="PackedScene" uid="uid://f1keiecsx5kw" path="res://skill/melee_area.tscn" id="2_q0v6t"] -[ext_resource type="AudioStream" uid="uid://cu5t5y3qadjd7" path="res://assets/audio/voices/swordwoman/swordwoman-special1-tempo-170.wav" id="3_uxa2s"] - -[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_rkutr"] -random_pitch = 1.05 -random_volume_offset_db = 2.0 -streams_count = 1 -stream_0/stream = ExtResource("3_uxa2s") -stream_0/weight = 1.0 [node name="Slash" type="Node3D"] script = ExtResource("1_dbiye") +voice_audio = ExtResource("2_ldjss") [node name="Area" parent="." instance=ExtResource("2_q0v6t")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1.8) - -[node name="Voice" type="AudioStreamPlayer3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0) -stream = SubResource("AudioStreamRandomizer_rkutr") -autoplay = true -bus = &"Voices" diff --git a/client/skill/slash/slash_voice.tres b/client/skill/slash/slash_voice.tres new file mode 100644 index 0000000..c965dc5 --- /dev/null +++ b/client/skill/slash/slash_voice.tres @@ -0,0 +1,10 @@ +[gd_resource type="AudioStreamRandomizer" load_steps=2 format=3 uid="uid://i2yim7wiuukw"] + +[ext_resource type="AudioStream" uid="uid://cu5t5y3qadjd7" path="res://assets/audio/voices/swordwoman/swordwoman-special1-tempo-170.wav" id="1_cowgf"] + +[resource] +random_pitch = 1.05 +random_volume_offset_db = 1.0 +streams_count = 1 +stream_0/stream = ExtResource("1_cowgf") +stream_0/weight = 1.0 diff --git a/client/skill/spin/spin.gd b/client/skill/spin/spin.gd index a1c2420..af398c7 100644 --- a/client/skill/spin/spin.gd +++ b/client/skill/spin/spin.gd @@ -1,6 +1,9 @@ extends AreaSkillInstance +@export var voice_audio: AudioStream + func _ready(): animation.play("human/spin", 2.0) + voice.play(voice_audio) await area_damage(0.5, 0.1, 0.4) end() \ No newline at end of file diff --git a/client/skill/spin/spin.tscn b/client/skill/spin/spin.tscn index 9eae8c9..9464846 100644 --- a/client/skill/spin/spin.tscn +++ b/client/skill/spin/spin.tscn @@ -1,27 +1,12 @@ -[gd_scene load_steps=6 format=3 uid="uid://bhrlgrleih7d0"] +[gd_scene load_steps=4 format=3 uid="uid://bhrlgrleih7d0"] [ext_resource type="Script" path="res://skill/spin/spin.gd" id="1_p5jmv"] +[ext_resource type="AudioStream" uid="uid://bwgmlkkxqbxoh" path="res://skill/spin/spin_voice.tres" id="2_bjl2j"] [ext_resource type="PackedScene" uid="uid://f1keiecsx5kw" path="res://skill/melee_area.tscn" id="2_fjxc1"] -[ext_resource type="AudioStream" uid="uid://t7ewt5tv8opw" path="res://assets/audio/voices/swordwoman/swordwoman-attack1.mp3" id="3_8hb6m"] -[ext_resource type="AudioStream" uid="uid://butmelbywp6iy" path="res://assets/audio/voices/swordwoman/swordwoman-attack2.mp3" id="4_j0bb6"] - -[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_bedvd"] -random_pitch = 1.05 -random_volume_offset_db = 2.0 -streams_count = 2 -stream_0/stream = ExtResource("3_8hb6m") -stream_0/weight = 1.0 -stream_1/stream = ExtResource("4_j0bb6") -stream_1/weight = 1.0 [node name="Spin" type="Node3D"] script = ExtResource("1_p5jmv") +voice_audio = ExtResource("2_bjl2j") [node name="Area" parent="." instance=ExtResource("2_fjxc1")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1.8) - -[node name="Voice" type="AudioStreamPlayer3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0) -stream = SubResource("AudioStreamRandomizer_bedvd") -autoplay = true -bus = &"Voices" diff --git a/client/skill/spin/spin_voice.tres b/client/skill/spin/spin_voice.tres new file mode 100644 index 0000000..925d90a --- /dev/null +++ b/client/skill/spin/spin_voice.tres @@ -0,0 +1,13 @@ +[gd_resource type="AudioStreamRandomizer" load_steps=3 format=3 uid="uid://bwgmlkkxqbxoh"] + +[ext_resource type="AudioStream" uid="uid://t7ewt5tv8opw" path="res://assets/audio/voices/swordwoman/swordwoman-attack1.mp3" id="1_cjplv"] +[ext_resource type="AudioStream" uid="uid://butmelbywp6iy" path="res://assets/audio/voices/swordwoman/swordwoman-attack2.mp3" id="2_prj6p"] + +[resource] +random_pitch = 1.05 +random_volume_offset_db = 1.0 +streams_count = 2 +stream_0/stream = ExtResource("1_cjplv") +stream_0/weight = 1.0 +stream_1/stream = ExtResource("2_prj6p") +stream_1/weight = 1.0