Added voice audio

This commit is contained in:
Eduard Urbach 2024-02-16 15:30:29 +01:00
parent 91f5167d6a
commit 89d730f0ae
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
13 changed files with 86 additions and 49 deletions

View File

@ -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="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"] [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://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://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://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://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="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"] [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://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://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="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://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://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://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="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://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"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_2f50n"]
radius = 0.3 radius = 0.3
@ -108,7 +109,15 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
strength = 15.0 strength = 15.0
radius = 2.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") skeleton = NodePath("../Model/Female/Armature/GeneralSkeleton")
movement = NodePath("../Movement") movement = NodePath("../Movement")
footsteps = SubResource("AudioStreamRandomizer_4yj1k") footsteps = SubResource("AudioStreamRandomizer_4yj1k")
@ -121,18 +130,13 @@ max_value = 100.0
[node name="Rotation" parent="." node_paths=PackedStringArray("root") instance=ExtResource("9_agxqu")] [node name="Rotation" parent="." node_paths=PackedStringArray("root") instance=ExtResource("9_agxqu")]
root = NodePath("..") 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")] [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")]) 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="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="Model/Female"]
[editable path="Animation"] [editable path="Animation"]

View File

@ -1,5 +1,5 @@
class_name AudioComponent class_name FootstepsComponent
extends Node3D extends Node
@export var skeleton: Skeleton3D @export var skeleton: Skeleton3D
@export var movement: MovementComponent @export var movement: MovementComponent

View File

@ -1,9 +1,9 @@
[gd_scene load_steps=2 format=3 uid="uid://clnfp813k7lep"] [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"] [node name="Footsteps" type="Node"]
script = ExtResource("1_0j3jl") script = ExtResource("1_xjrot")
[node name="LeftFoot" type="AudioStreamPlayer3D" parent="."] [node name="LeftFoot" type="AudioStreamPlayer3D" parent="."]
max_distance = 20.0 max_distance = 20.0

View File

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

View File

@ -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"

View File

@ -3,10 +3,12 @@ extends Node
var state: StateComponent var state: StateComponent
var animation: AnimationComponent var animation: AnimationComponent
var voice: VoiceComponent
func _enter_tree(): func _enter_tree():
state = get_parent().get_node("State") as StateComponent state = get_parent().get_node("State") as StateComponent
animation = get_parent().get_node("Animation") as AnimationComponent animation = get_parent().get_node("Animation") as AnimationComponent
voice = get_parent().get_node("Voice") as VoiceComponent
state.current = StateComponent.State.Skill state.current = StateComponent.State.Skill
func end(): func end():

View File

@ -1,6 +1,9 @@
extends AreaSkillInstance extends AreaSkillInstance
@export var voice_audio: AudioStream
func _ready(): func _ready():
animation.play("human/slash", 1.7) animation.play("human/slash", 1.7)
voice.play(voice_audio)
await area_damage(0.5, 0.1, 0.2) await area_damage(0.5, 0.1, 0.2)
end() end()

View File

@ -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="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="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"] [node name="Slash" type="Node3D"]
script = ExtResource("1_dbiye") script = ExtResource("1_dbiye")
voice_audio = ExtResource("2_ldjss")
[node name="Area" parent="." instance=ExtResource("2_q0v6t")] [node name="Area" parent="." instance=ExtResource("2_q0v6t")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1.8) 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"

View File

@ -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

View File

@ -1,6 +1,9 @@
extends AreaSkillInstance extends AreaSkillInstance
@export var voice_audio: AudioStream
func _ready(): func _ready():
animation.play("human/spin", 2.0) animation.play("human/spin", 2.0)
voice.play(voice_audio)
await area_damage(0.5, 0.1, 0.4) await area_damage(0.5, 0.1, 0.4)
end() end()

View File

@ -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="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="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"] [node name="Spin" type="Node3D"]
script = ExtResource("1_p5jmv") script = ExtResource("1_p5jmv")
voice_audio = ExtResource("2_bjl2j")
[node name="Area" parent="." instance=ExtResource("2_fjxc1")] [node name="Area" parent="." instance=ExtResource("2_fjxc1")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1.8) 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"

View File

@ -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