Fixed AudioPlayer's file path parsing trouble. Twekaed sound playback parameters (volume, attenuation).

remotes/1711660107545182331/update-godot-to-1852afb6b
unfa 2021-09-12 03:48:39 +02:00
parent d1b8b5eb6b
commit 428188488d
12 changed files with 93 additions and 43 deletions

View File

@ -18,7 +18,7 @@ var ready_to_play = true # used as a semaphor for MinDelay
var voices = []
var voice = 0
var debug = false
var debug = true
func _ready():
var files = []
@ -29,20 +29,24 @@ func _ready():
if debug:
print("SoundClip: ", SoundClip)
# determine the sound group name part
var group = SoundClip.left(SoundClip.rfind('_') -2).right(SoundClip.rfind('/') + 1)
#var group = SoundClip.left(SoundClip.rfind('_') -2).right(SoundClip.rfind('/') + 1)
#var group = SoundClip.left(SoundClip.rfind('_')).right(SoundClip.rfind('/'))
var group = SoundClip.trim_prefix("res://").trim_suffix('_01.wav').get_file()
if false: # temporarily disabled, needs work
# determine the sound layer name part
var layer = SoundClip.right(SoundClip.rfind('01') + 1)
layer = layer.right(layer.rfind('_') - 1)
layer = layer.left(layer.rfind('.') -2)
layer = layer.right(layer.rfind('_') -1)
layer = layer.left(layer.rfind('.') - 2)
if layer == "1": # sound without a layer defined will return "1", so let's take that as a "no layers defined in this sound"
layer = ""
else: # if the layers was specified the group will be incorrectly including the variant number, let's fix that
group = group.left(group.rfind('_'))
if debug:
print("group: ", group)
print("layer: ", layer)
if debug:
print("group: ", group)
#print("layer: ", layer)
while true:
var file = dir.get_next()
@ -83,8 +87,8 @@ func _ready():
min_distance = 0
#print ("Clips: ", len(clips))
#print ("min_distance: ", min_distance)
print("Clips: ", len(clips))
print("min_distance: ", min_distance)
# prepare voices - TODO: this does not work! as aworkaround I've duplicated the secondary AudioStreamPlayer3D manually
if Voice_Count > 1:

View File

@ -4,7 +4,6 @@
[node name="SoundPlayer" type="Node3D"]
script = ExtResource( "1_uq1fs" )
PitchScale = 1.014
[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="."]
unit_size = 6.0

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://egphnvwk6cg"]
[gd_scene load_steps=6 format=3 uid="uid://egphnvwk6cg"]
[ext_resource type="Script" path="res://Assets/Effects/Gibs.gd" id="1_o0guu"]
[ext_resource type="PackedScene" uid="uid://c5cwnfuw4go1b" path="res://Assets/Audio/SoundPlayer.tscn" id="2_3tb4k"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_3sp1q"]
albedo_color = Color(0.509804, 0.0235294, 0, 1)
@ -38,4 +39,8 @@ one_shot = true
autostart = true
script = null
[node name="SoundPlayer" parent="." instance=ExtResource( "2_3tb4k" )]
SoundClip = "res://Assets/SFX/Player_Death_01.wav"
AutoPlay = true
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]

View File

@ -1,20 +1,7 @@
extends Node3D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
$CPUParticles3D.emitting = true
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _on_Timer_timeout():
queue_free()

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=9 format=3 uid="uid://egphnvwk6cg"]
[gd_scene load_steps=10 format=3 uid="uid://egphnvwk6cg"]
[ext_resource type="Script" path="res://Assets/Effects/Impact.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://cguy76rs8e220" path="res://Assets/Effects/Flame.png" id="2"]
[ext_resource type="PackedScene" uid="uid://c5cwnfuw4go1b" path="res://Assets/Audio/SoundPlayer.tscn" id="3_ftpj2"]
[sub_resource type="StandardMaterial3D" id="7"]
blend_mode = 3
@ -67,4 +68,14 @@ mesh = SubResource( "6" )
surface_material_override/0 = null
script = null
[node name="SoundPlayer" parent="." instance=ExtResource( "3_ftpj2" )]
SoundClip = "res://Assets/SFX/Weapons_BulletHitPlayer_01.wav"
AutoPlay = true
[node name="AudioStreamPlayer3D" parent="SoundPlayer" index="0"]
unit_db = -3.0
unit_size = 2.0
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
[editable path="SoundPlayer"]

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=11 format=3 uid="uid://d1yx12uryxl26"]
[gd_scene load_steps=12 format=3 uid="uid://d1yx12uryxl26"]
[ext_resource type="Script" path="res://Assets/Effects/Impact.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://cguy76rs8e220" path="res://Assets/Effects/Flame.png" id="2"]
[ext_resource type="PackedScene" uid="uid://c5cwnfuw4go1b" path="res://Assets/Audio/SoundPlayer.tscn" id="3_oh3bk"]
[sub_resource type="StandardMaterial3D" id="1"]
blend_mode = 1
@ -136,4 +137,15 @@ anims/anim = SubResource( "8" )
blend_times = []
script = null
[node name="SoundPlayer" parent="." instance=ExtResource( "3_oh3bk" )]
SoundClip = "res://Assets/SFX/Weapons_BulletHitWall_01.wav"
AutoPlay = true
RandomizePitch = 0.1
[node name="AudioStreamPlayer3D" parent="SoundPlayer" index="0"]
unit_db = -8.0
unit_size = 2.0
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
[editable path="SoundPlayer"]

View File

@ -133,6 +133,7 @@ script = null
[node name="ConfirmSound" type="AudioStreamPlayer" parent="Crosshair"]
stream = ExtResource( "4_llqcq" )
volume_db = 6.0
script = null
[node name="Vignette" type="TextureRect" parent="."]

View File

@ -56,7 +56,7 @@ var impact_player = preload("res://Assets/Effects/ImpactBlood.tscn")
else:
impact_vfx = impact_wall.instantiate()
if impact_vfx:
if impact_vfx != null:
impact_vfx.global_transform = impact_vfx.global_transform.looking_at(ray['normal'])
impact_vfx.global_transform.origin = ray['position']
get_tree().root.add_child(impact_vfx)

View File

@ -50,5 +50,12 @@ script = null
[node name="Shoot" parent="Handgun/SFX" instance=ExtResource( "3_q0xp7" )]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0168038, 0.251726, 0.250185)
SoundClip = "res://Assets/SFX/Weapons_HandgunShot_01.wav"
Voice_Count = 2
[node name="AudioStreamPlayer3D" parent="Handgun/SFX/Shoot" index="0"]
unit_db = 6.0
unit_size = 8.0
max_db = 6.0
[editable path="Handgun"]
[editable path="Handgun/SFX/Shoot"]

View File

@ -6,8 +6,8 @@ enum NetworkRole {NONE, CLIENT, SERVER, DEDICATED_SERVER, RELAY_SERVER}
const NET_PORT = 12597
const NET_SERVER = "liblast.unfa.xyz"
#const NET_SERVER = "localhost"
#const NET_SERVER = "liblast.unfa.xyz"
const NET_SERVER = "localhost"
var peer = ENetMultiplayerPeer.new()
@ -371,3 +371,7 @@ func _on_ColorPickerButton_color_changed(color):
player_list.players[get_tree().multiplayer.get_network_unique_id()].color = color
push_local_player_info()
#local_player.rpc(&'set_color', color)
func _on_CheckButton_toggled(button_pressed):
AudioServer.set_bus_mute(0, button_pressed)

View File

@ -50,24 +50,34 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1)
[node name="NetworkTesting" type="VBoxContainer" parent="."]
anchor_left = 1.0
anchor_right = 1.0
offset_left = -166.0
offset_bottom = 159.0
offset_left = -188.0
offset_bottom = 176.0
script = null
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}
[node name="CheckButton" type="CheckButton" parent="NetworkTesting"]
offset_right = 188.0
offset_bottom = 40.0
text = "MUTE SOUND"
script = null
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Host" type="Button" parent="NetworkTesting"]
offset_right = 166.0
offset_bottom = 29.0
offset_top = 44.0
offset_right = 188.0
offset_bottom = 73.0
text = "Host"
script = null
[node name="Connect" type="Button" parent="NetworkTesting"]
offset_top = 33.0
offset_right = 166.0
offset_bottom = 62.0
offset_top = 77.0
offset_right = 188.0
offset_bottom = 106.0
text = "Connect"
script = null
__meta__ = {
@ -75,18 +85,18 @@ __meta__ = {
}
[node name="TextEdit" type="LineEdit" parent="NetworkTesting"]
offset_top = 66.0
offset_right = 166.0
offset_bottom = 99.0
offset_top = 110.0
offset_right = 188.0
offset_bottom = 143.0
rect_min_size = Vector2(100, 30)
text = "name"
structured_text_bidi_override_options = []
script = null
[node name="ColorPickerButton" type="ColorPickerButton" parent="NetworkTesting"]
offset_top = 103.0
offset_right = 166.0
offset_bottom = 132.0
offset_top = 147.0
offset_right = 188.0
offset_bottom = 176.0
edit_alpha = false
script = null
__meta__ = {
@ -107,6 +117,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 17, 0)
visible = false
script = null
[connection signal="toggled" from="NetworkTesting/CheckButton" to="." method="_on_CheckButton_toggled"]
[connection signal="pressed" from="NetworkTesting/Host" to="." method="_on_Host_pressed"]
[connection signal="pressed" from="NetworkTesting/Connect" to="." method="_on_Connect_pressed"]
[connection signal="text_submitted" from="NetworkTesting/TextEdit" to="." method="_on_TextEdit_text_submitted"]

View File

@ -0,0 +1,9 @@
[gd_resource type="AudioBusLayout" load_steps=2 format=3 uid="uid://b1tuvipfxjwsx"]
[sub_resource type="AudioEffectLimiter" id="AudioEffectLimiter_34kb8"]
resource_name = "Limiter"
ceiling_db = -1.0
[resource]
bus/0/effect/0/effect = SubResource( "AudioEffectLimiter_34kb8" )
bus/0/effect/0/enabled = true