Fixed audio randomization, and typos. Other fixes. Added voicing support.

remotes/1699085073425121156/tmp_refs/heads/announcer
unfa 2021-04-07 23:28:34 +02:00
parent c1196cb44f
commit 7166becf15
36 changed files with 311 additions and 285 deletions

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handgun_Casing.wav-839263cc631e3c65b5e4e801f3aa44fb.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handgun_Casing.wav"
dest_files=[ "res://.import/Weapons_Handgun_Casing.wav-839263cc631e3c65b5e4e801f3aa44fb.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handgun_Shot_01_A.wav-c05fdc66e1616fe4a8ba40743a60eeb4.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handgun_Shot_01_A.wav"
dest_files=[ "res://.import/Weapons_Handgun_Shot_01_A.wav-c05fdc66e1616fe4a8ba40743a60eeb4.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handgun_Shot_01_B.wav-3ccb4c78c871272fb8879117beb1a0b2.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handgun_Shot_01_B.wav"
dest_files=[ "res://.import/Weapons_Handgun_Shot_01_B.wav-3ccb4c78c871272fb8879117beb1a0b2.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handgun_Shot_01_C.wav-0c2d5b4b21322c6a0669c299279ea183.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handgun_Shot_01_C.wav"
dest_files=[ "res://.import/Weapons_Handgun_Shot_01_C.wav-0c2d5b4b21322c6a0669c299279ea183.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handgun_Shot_02_A.wav-c1466b41d37e4602fd3b0300280b0a24.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handgun_Shot_02_A.wav"
dest_files=[ "res://.import/Weapons_Handgun_Shot_02_A.wav-c1466b41d37e4602fd3b0300280b0a24.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handgun_Shot_02_B.wav-827fb39726fbf8f1250f0eeff39e9ea5.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handgun_Shot_02_B.wav"
dest_files=[ "res://.import/Weapons_Handgun_Shot_02_B.wav-827fb39726fbf8f1250f0eeff39e9ea5.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -2,12 +2,12 @@
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handun_Shot_02_A.wav-59af1bc71ddcc00f6f73dc8b1cc905dc.sample"
path="res://.import/Weapons_Handgun_Shot_02_C.wav-14e8a0762dff6450289c1517347f8ca3.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handun_Shot_02_A.wav"
dest_files=[ "res://.import/Weapons_Handun_Shot_02_A.wav-59af1bc71ddcc00f6f73dc8b1cc905dc.sample" ]
source_file="res://Assets/Audio/SFX/Weapons_Handgun_Shot_02_C.wav"
dest_files=[ "res://.import/Weapons_Handgun_Shot_02_C.wav-14e8a0762dff6450289c1517347f8ca3.sample" ]
[params]

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handgun_Shot_03_A.wav-326a10d3ba2c5dc2d19f23024f54c946.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handgun_Shot_03_A.wav"
dest_files=[ "res://.import/Weapons_Handgun_Shot_03_A.wav-326a10d3ba2c5dc2d19f23024f54c946.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handgun_Shot_03_B.wav-f230cad0f09352f26fc6484a92997f5f.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handgun_Shot_03_B.wav"
dest_files=[ "res://.import/Weapons_Handgun_Shot_03_B.wav-f230cad0f09352f26fc6484a92997f5f.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handgun_Shot_03_C.wav-1d9f6127b219fbb7e068be534e19d26a.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handgun_Shot_03_C.wav"
dest_files=[ "res://.import/Weapons_Handgun_Shot_03_C.wav-1d9f6127b219fbb7e068be534e19d26a.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -1,21 +0,0 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handun_Casing.wav-195398e93ac67de2637914a996b7c6c3.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handun_Casing.wav"
dest_files=[ "res://.import/Weapons_Handun_Casing.wav-195398e93ac67de2637914a996b7c6c3.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -1,21 +0,0 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handun_Shot_01_A.wav-b5049ef4e85c0808d916a354169d81be.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handun_Shot_01_A.wav"
dest_files=[ "res://.import/Weapons_Handun_Shot_01_A.wav-b5049ef4e85c0808d916a354169d81be.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -1,21 +0,0 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handun_Shot_01_B.wav-91e94d7b9c40af17e0b85445c3cd4794.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handun_Shot_01_B.wav"
dest_files=[ "res://.import/Weapons_Handun_Shot_01_B.wav-91e94d7b9c40af17e0b85445c3cd4794.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -1,21 +0,0 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handun_Shot_01_C.wav-5bd4324dcd7f9d7616ebe5cd03928aa4.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handun_Shot_01_C.wav"
dest_files=[ "res://.import/Weapons_Handun_Shot_01_C.wav-5bd4324dcd7f9d7616ebe5cd03928aa4.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -1,21 +0,0 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handun_Shot_02_B.wav-6db638e923eff625fc24be7746e3cbf9.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handun_Shot_02_B.wav"
dest_files=[ "res://.import/Weapons_Handun_Shot_02_B.wav-6db638e923eff625fc24be7746e3cbf9.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -1,21 +0,0 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handun_Shot_02_C.wav-7976192c394ee6f94fbbf58e48ecf770.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handun_Shot_02_C.wav"
dest_files=[ "res://.import/Weapons_Handun_Shot_02_C.wav-7976192c394ee6f94fbbf58e48ecf770.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -1,21 +0,0 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handun_Shot_03_A.wav-8995aec4a701c64d2659a79326402ecb.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handun_Shot_03_A.wav"
dest_files=[ "res://.import/Weapons_Handun_Shot_03_A.wav-8995aec4a701c64d2659a79326402ecb.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -1,21 +0,0 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handun_Shot_03_B.wav-0ec5401d1dee25f9fe11ace2be944c05.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handun_Shot_03_B.wav"
dest_files=[ "res://.import/Weapons_Handun_Shot_03_B.wav-0ec5401d1dee25f9fe11ace2be944c05.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -1,21 +0,0 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Handun_Shot_03_C.wav-3e9fd58bf53f5166e71559cd82c6c971.sample"
[deps]
source_file="res://Assets/Audio/SFX/Weapons_Handun_Shot_03_C.wav"
dest_files=[ "res://.import/Weapons_Handun_Shot_03_C.wav-3e9fd58bf53f5166e71559cd82c6c971.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -1,38 +1,14 @@
[gd_scene load_steps=14 format=2]
[gd_scene load_steps=10 format=2]
[ext_resource path="res://Assets/Weapons/GrenadeLauncher/GranadeLauncher.gltf" type="PackedScene" id=1]
[ext_resource path="res://Classes/Weapon/Weapon.gd" type="Script" id=2]
[ext_resource path="res://Assets/Audio/SFX/Weapons_Handun_Shot_01_A.wav" type="AudioStream" id=3]
[ext_resource path="res://Classes/Audio/LayeredSoundPlayer.gd" type="Script" id=3]
[ext_resource path="res://Assets/Effects/CircleSoft.svg" type="Texture" id=4]
[ext_resource path="res://Assets/Audio/SFX/Weapons_Empty.wav" type="AudioStream" id=5]
[ext_resource path="res://Assets/Audio/SFX/Weapons_Handgun_Reload.wav" type="AudioStream" id=6]
[ext_resource path="res://Classes/Audio/SoundPlayer.tscn" type="PackedScene" id=7]
[sub_resource type="Gradient" id=1]
offsets = PoolRealArray( 0, 0.0511628, 0.0883721, 0.302326, 1 )
colors = PoolColorArray( 0, 0, 0, 1, 2, 2, 2, 1, 0.901961, 0.866667, 0.576471, 1, 0.909804, 0.592157, 0.168627, 1, 0, 0, 0, 1 )
[sub_resource type="GradientTexture" id=2]
gradient = SubResource( 1 )
[sub_resource type="Curve" id=3]
_data = [ Vector2( 0, 0.986364 ), 0.0, -0.872434, 0, 0, Vector2( 0.092437, 0.752585 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.198039 ), -0.85103, 0.0, 0, 0 ]
[sub_resource type="CurveTexture" id=4]
curve = SubResource( 3 )
[sub_resource type="ParticlesMaterial" id=5]
direction = Vector3( 0, 0, -5 )
spread = 15.0
gravity = Vector3( 0, 0, 0 )
initial_velocity = 8.0
initial_velocity_random = 0.75
damping = 100.0
damping_random = 0.5
scale_random = 1.0
scale_curve = SubResource( 4 )
color_ramp = SubResource( 2 )
[sub_resource type="SpatialMaterial" id=6]
[sub_resource type="SpatialMaterial" id=1]
flags_transparent = true
flags_unshaded = true
vertex_color_use_as_albedo = true
@ -43,15 +19,27 @@ particles_anim_v_frames = 1
particles_anim_loop = false
albedo_texture = ExtResource( 4 )
[sub_resource type="QuadMesh" id=7]
material = SubResource( 6 )
[sub_resource type="QuadMesh" id=2]
size = Vector2( 0.3, 0.3 )
[node name="Weapon" type="Spatial"]
script = ExtResource( 2 )
[node name="MuzzleFlash" type="Particles" parent="."]
transform = Transform( -4.37113e-08, 0, 0.999999, 0, 0.999999, 0, -1, 0, -4.37114e-08, -0.562363, 0.0926898, 0 )
[node name="Model" parent="." instance=ExtResource( 1 )]
[node name="Effects" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.68988, 0.110679, 0 )
[node name="Flash" type="AnimationPlayer" parent="Effects"]
[node name="MuzzleLight" type="OmniLight" parent="Effects"]
light_color = Color( 1, 0.423529, 0.0431373, 1 )
light_energy = 0.0
omni_range = 10.0
omni_attenuation = 2.92817
[node name="MuzzleFlash" type="Particles" parent="Effects"]
transform = Transform( -4.37113e-08, 0, 0.999999, 0, 0.999999, 0, -1, 0, -4.37114e-08, 0.38458, 0.0133779, 0 )
cast_shadow = 0
emitting = false
amount = 16
@ -59,27 +47,46 @@ lifetime = 0.1
one_shot = true
explosiveness = 1.0
visibility_aabb = AABB( -0.176241, -0.185755, -0.556571, 0.352482, 0.37151, 0.655134 )
process_material = SubResource( 5 )
draw_pass_1 = SubResource( 7 )
[node name="GranadeLauncher" parent="." instance=ExtResource( 1 )]
process_material = SubResource( 1 )
draw_pass_1 = SubResource( 2 )
[node name="Sounds" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.295478, 0.724833, 0.584699 )
[node name="SoundShoot" type="AudioStreamPlayer3D" parent="Sounds"]
transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0 )
stream = ExtResource( 3 )
attenuation_model = 3
unit_db = 3.0
unit_size = 25.0
pitch_scale = 0.5
emission_angle_enabled = true
emission_angle_degrees = 60.0
attenuation_filter_cutoff_hz = 15000.0
[node name="SoundEmpty" type="AudioStreamPlayer3D" parent="Sounds"]
[node name="Empty" type="AudioStreamPlayer3D" parent="Sounds"]
stream = ExtResource( 5 )
[node name="SoundReload" type="AudioStreamPlayer3D" parent="Sounds"]
[node name="Reload" type="AudioStreamPlayer3D" parent="Sounds"]
stream = ExtResource( 6 )
[node name="Shoot" type="Spatial" parent="Sounds"]
script = ExtResource( 3 )
[node name="A" parent="Sounds/Shoot" instance=ExtResource( 7 )]
SoundClip = "res://Assets/Audio/SFX/Weapons_Handgun_Shot_01_A.wav"
AutoPlay = false
MinimumRandomDistance = 0.35
PlayUntilEnd = false
MinDelay = 0.0
PitchScale = 1.0
RandomizePitch = 0.05
[node name="B" parent="Sounds/Shoot" instance=ExtResource( 7 )]
SoundClip = "res://Assets/Audio/SFX/Weapons_Handgun_Shot_01_B.wav"
AutoPlay = false
MinimumRandomDistance = 0.35
PlayUntilEnd = false
MinDelay = 0.0
PitchScale = 1.0
RandomizePitch = 0.05
[node name="C" parent="Sounds/Shoot" instance=ExtResource( 7 )]
SoundClip = "res://Assets/Audio/SFX/Weapons_Handgun_Shot_01_C.wav"
AutoPlay = false
MinimumRandomDistance = 0.35
PlayUntilEnd = false
MinDelay = 0.0
PitchScale = 1.0
RandomizePitch = 0.05
[editable path="Model"]

View File

@ -2,7 +2,7 @@
[ext_resource path="res://Assets/Weapons/Handgun/Casing.material" type="Material" id=1]
[ext_resource path="res://Assets/Weapons/Handgun/Casing.gd" type="Script" id=2]
[ext_resource path="res://Assets/Audio/SFX/Weapons_Handun_Casing.wav" type="AudioStream" id=3]
[ext_resource path="res://Assets/Audio/SFX/Weapons_Handgun_Casing.wav" type="AudioStream" id=3]
[ext_resource path="res://Assets/Effects/SubtleSmoke.png" type="Texture" id=4]
[ext_resource path="res://addons/Trail/trail_3d.gd" type="Script" id=5]

View File

@ -91,13 +91,7 @@ size = Vector2( 0.3, 0.3 )
[node name="Weapon" type="Spatial"]
script = ExtResource( 2 )
[node name="Handgun" parent="." instance=ExtResource( 1 )]
[node name="Muzzle" parent="Handgun" index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.331868, 0.125291, 0 )
[node name="Ejector" parent="Handgun" index="1"]
transform = Transform( -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0, 1, -0.0373496, 0.126382, -0.00737098 )
[node name="Model" parent="." instance=ExtResource( 1 )]
[node name="Effects" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.68988, 0.110679, 0 )
@ -136,15 +130,16 @@ stream = ExtResource( 6 )
script = ExtResource( 3 )
[node name="A" parent="Sounds/Shoot" instance=ExtResource( 7 )]
SoundClip = "res://Assets/Audio/SFX/Weapons_Handun_Shot_01_A.wav"
SoundClip = "res://Assets/Audio/SFX/Weapons_Handgun_Shot_01_A.wav"
RandomizePitch = 0.05
Voice_Count = 2
[node name="B" parent="Sounds/Shoot" instance=ExtResource( 7 )]
SoundClip = "res://Assets/Audio/SFX/Weapons_Handun_Shot_01_B.wav"
SoundClip = "res://Assets/Audio/SFX/Weapons_Handgun_Shot_01_B.wav"
RandomizePitch = 0.05
Voice_Count = 2
[node name="C" parent="Sounds/Shoot" instance=ExtResource( 7 )]
SoundClip = "res://Assets/Audio/SFX/Weapons_Handun_Shot_01_C.wav"
SoundClip = "res://Assets/Audio/SFX/Weapons_Handgun_Shot_01_C.wav"
RandomizePitch = 0.05
[editable path="Handgun"]
Voice_Count = 2

View File

@ -4,8 +4,6 @@ extends Spatial
const SFX_dir = "res://Assets/Audio/SFX/" # all sound clips must reside somewhere in this directory
onready var player = $AudioStreamPlayer3D # playback backend
export(String, FILE, "*01*.wav") var SoundClip = SFX_dir + "Test_01.wav"
export(bool) var AutoPlay = false
export(float) var MinimumRandomDistance = 0.35 # gives optimal playback repetition for sound clip groups of different sizes.
@ -13,11 +11,14 @@ export(bool) var PlayUntilEnd = false # determines if the play() function is all
export(float) var MinDelay = 0 # determines how many seconds must pass before the sound can be triggered again
export(float) var PitchScale = 1
export(float) var RandomizePitch = 0
export(int) var Voice_Count = 1
var min_distance = 0 # this determines how ofte na sound is allowed to play (any Nth time) this is calculated automatically based on maximum_repetition
var clips = [] # holds loaded sound stream resources
var recently_played = [] # holds indexes of recently played
var ready = true # used as a semaphor for MinDelay
var voices = []
var voice = 0
# Called when the node enters the scene tree for the first time.
func _ready():
@ -36,6 +37,8 @@ func _ready():
layer = layer.left(layer.find_last('.'))
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.find_last('_'))
print("group: ", group)
print("layer: ", layer)
@ -48,21 +51,43 @@ func _ready():
elif not file.begins_with(".") and file.begins_with(group) and file.ends_with(".wav"):
if layer.length() == 0: # no layer specified?
files.append(file)
print("no layer specified - adding ", file)
elif file.find(layer) > -1: # chek if the file name contains the layer string
files.append(file)
print("layer matches - adding ", file)
dir.list_dir_end()
#print(files)
print("files in list: \n", files)
for f in files:
clips.append(load(SFX_dir + f))
var res_file = SFX_dir + f
var clip = load(res_file)
clips.append(clip)
print("loading ", res_file, "; result: ", clip)
var clip_count = clips.size()
if not MinimumRandomDistance == null:
min_distance = floor(clip_count * MinimumRandomDistance)
else:
min_distance = 0
min_distance = floor(len(clips) * MinimumRandomDistance)
#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:
for i in range(1, Voice_Count):
var new_voice = $AudioStreamPlayer3D.duplicate()
add_child(new_voice)
for i in get_children():
voices.append(i)
print("voices: ", voices)
if AutoPlay:
play()
@ -71,6 +96,11 @@ func pick_random():
return randi() % len(clips)
sync func play():
var player = voices[voice]
voice = (voice + 1) % voices.size()
print("playing ", name, " on voice ", voice)
if PlayUntilEnd:
if player.playing:
@ -92,7 +122,7 @@ sync func play():
if len(recently_played) > min_distance:
recently_played.remove(0)
#print("recently played: ", recently_played)
print("random pick: ", clips[i])
player.stream = clips[i]

View File

@ -6,5 +6,6 @@
script = ExtResource( 1 )
[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="."]
unit_size = 6.0
attenuation_filter_cutoff_hz = 20000.0
attenuation_filter_db = 0.0

View File

@ -37,7 +37,7 @@ func shoot(camera):
if currently_fireing == true:
cached_fire = true
yield($Handgun/AnimationPlayer, "animation_finished")
yield($Model/AnimationPlayer, "animation_finished")
# TODO: mutexes
currently_fireing = true
@ -77,7 +77,7 @@ sync func fire_weapon(var rounds_left):
show_muzzle_flash(rounds_left)
show_tracer()
spawn_casing()
yield($Handgun/AnimationPlayer, "animation_finished")
yield($Model/AnimationPlayer, "animation_finished")
if !cached_fire:
currently_fireing = false
@ -86,12 +86,12 @@ sync func dry_fire():
pass
func show_muzzle_flash(var rounds_left):
$Handgun/AnimationPlayer.stop()
$Model/AnimationPlayer.stop()
if rounds_left == 1:
$Handgun/AnimationPlayer.play("Empty", -1, 2)
$Model/AnimationPlayer.play("Empty", -1, 2)
else:
$Handgun/AnimationPlayer.play("Shoot", -1, 2)
$Model/AnimationPlayer.play("Shoot", -1, 2)
$Effects/Flash.stop(true)
$Effects/Flash.play("Flash")
@ -142,7 +142,7 @@ func reload():
currently_fireing = true
cached_fire = false
yield($Handgun/AnimationPlayer, "animation_finished")
yield($Model/AnimationPlayer, "animation_finished")
if not cached_fire:
currently_fireing = false
@ -152,5 +152,5 @@ func reload():
emit_signal("ammo_changed", "handgun", current_rounds)
sync func play_reload_animation():
$Handgun/AnimationPlayer.play("Reload", 0.5, 1)
$Model/AnimationPlayer.play("Reload", 0.5, 1)
$Sounds/Reload.play()

View File

@ -91,6 +91,8 @@ size = Vector2( 0.3, 0.3 )
[node name="Weapon" type="Spatial"]
script = ExtResource( 2 )
[node name="Model" parent="." instance=ExtResource( 1 )]
[node name="Effects" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.68988, 0.110679, 0 )
@ -115,14 +117,6 @@ visibility_aabb = AABB( -0.176241, -0.185755, -0.556571, 0.352482, 0.37151, 0.65
process_material = SubResource( 6 )
draw_pass_1 = SubResource( 8 )
[node name="Handgun" parent="." instance=ExtResource( 1 )]
[node name="Muzzle" parent="Handgun" index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.331868, 0.125291, 0 )
[node name="Ejector" parent="Handgun" index="1"]
transform = Transform( -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0, 1, -0.0373496, 0.126382, -0.00737098 )
[node name="Sounds" type="Spatial" parent="."]
transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 1.21559, 1.34154, 0.732928 )
@ -136,31 +130,30 @@ stream = ExtResource( 5 )
script = ExtResource( 6 )
[node name="A" parent="Sounds/Shoot" instance=ExtResource( 3 )]
SoundClip = "res://Assets/Audio/SFX/Weapons_Handun_Shot_01_A.wav"
RandomizePitch = 0.05
SoundClip = "res://Assets/Audio/SFX/Weapons_Handgun_Shot_01_A.wav"
RandomizePitch = 0.01
Voice_Count = 2
[node name="AudioStreamPlayer3D" parent="Sounds/Shoot/A" index="0"]
unit_size = 0.1
attenuation_filter_db = -6.0
[node name="B" parent="Sounds/Shoot" instance=ExtResource( 3 )]
SoundClip = "res://Assets/Audio/SFX/Weapons_Handun_Shot_01_B.wav"
RandomizePitch = 0.05
SoundClip = "res://Assets/Audio/SFX/Weapons_Handgun_Shot_01_B.wav"
RandomizePitch = 0.01
Voice_Count = 2
[node name="AudioStreamPlayer3D" parent="Sounds/Shoot/B" index="0"]
unit_db = -3.0
unit_size = 2.0
[node name="C" parent="Sounds/Shoot" instance=ExtResource( 3 )]
SoundClip = "res://Assets/Audio/SFX/Weapons_Handun_Shot_01_C.wav"
RandomizePitch = 0.05
SoundClip = "res://Assets/Audio/SFX/Weapons_Handgun_Shot_01_C.wav"
RandomizePitch = 0.01
Voice_Count = 2
[node name="AudioStreamPlayer3D" parent="Sounds/Shoot/C" index="0"]
unit_db = -3.0
unit_size = 6.0
max_db = 6.0
[editable path="Handgun"]
[editable path="Sounds/Shoot/A"]