Implemented player land sound

Also added option to remotely set unit_db on SoundPlayer
Removed debug prints in WindSFX and Player
feature-rocketlauncher
unfa 2021-12-18 17:04:29 +01:00
parent 4579bf5743
commit 32a7aba47c
7 changed files with 150 additions and 11 deletions

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="241.88976"
height="241.88977"
viewBox="0 0 63.999996 64"
version="1.1"
id="svg8"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20, custom)"
sodipodi:docname="MuteIcon.svg"
inkscape:export-filename="/data/Projects/Games/Liblast/Game/Assets/HUD/MuteIcon.png"
inkscape:export-xdpi="25.400002"
inkscape:export-ydpi="25.400002"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:zoom="2.8284271"
inkscape:cx="136.82516"
inkscape:cy="119.14749"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
inkscape:pagecheckerboard="true"
borderlayer="true"
units="px"
inkscape:window-width="1920"
inkscape:window-height="1003"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g4003"
transform="matrix(1.4835249,0,0,1.4835249,-14.236037,-15.107458)"
style="stroke-width:0.67407">
<path
id="rect2849"
style="fill:#ffffff;stroke:none;stroke-width:0.460391;stroke-linecap:round;stroke-linejoin:round;paint-order:markers stroke fill"
d="M 44.775584,10.98963 30.990895,21.705255 V 41.802221 L 44.775584,52.517845 Z M 20.325913,21.705255 c -1.533872,0 -2.768823,1.234434 -2.768823,2.768307 v 14.559834 c 0,1.533871 1.234951,2.768825 2.768823,2.768825 h 5.792411 2.768306 V 39.033396 24.473562 21.705255 h -2.768306 z" />
</g>
<path
style="fill:none;stroke:#ff0000;stroke-width:4.065;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 3.5033357,48.546698 60.496661,15.453304"
id="path3885" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -111,6 +111,9 @@ func pick_random():
assert(len(clips) > 0, "SoundPlayer has no clips to choose from")
return randi() % len(clips)
@rpc(call_local, any_peer, reliable) func set_unit_db(value):
$AudioStreamPlayer3D.unit_db = value
@rpc(call_local, any_peer, reliable) func play():
# temporary

View File

@ -31,7 +31,7 @@ func _physics_process(delta):
playing = false
var speed = get_parent().get_parent().motion_velocity.length()
print("speed: ", speed)
#print("speed: ", speed)
if speed > min_speed + min_speed_hysteresis / 2:
stream_paused = false
@ -39,7 +39,7 @@ func _physics_process(delta):
stream_paused = true
volume_db = speed_to_volume.interpolate_baked(speed / max_speed)
print(volume_db)
#print(volume_db)
audio_filter.cutoff_hz = speed_to_cutoff.interpolate_baked(speed / max_speed) * 10 # cnvert to 0-1 kHz range
print(audio_filter.cutoff_hz)
#print(audio_filter.cutoff_hz)

View File

@ -111,8 +111,8 @@ var velocity := Vector3.ZERO
var gravity_vec := Vector3.ZERO
var previously_on_floor := false
var lagging_movement_velocity = Vector3.ZERO
var previous_motion_velocity := Vector3.ZERO
var lagging_movement_velocity := Vector3.ZERO
var dead = false#: # used to workaround Godot crash when destroying player_nodes
# set(value):
@ -505,17 +505,34 @@ func _physics_process(delta):
$Head/Camera/Hand/Weapon.transform.origin.y -= 0.025
#$Head/Camera/Hand/Weapon.transform.origin.y -= 0.05
if is_on_floor() and not previously_on_floor:
$Head/Camera/Hand/Weapon.transform.origin.y -= 1
if is_on_floor() and not previously_on_floor: # we just landed from a jump or fall
var impact = (motion_velocity - previous_motion_velocity).length_squared()
#print ("impact: ", impact)
$Head/Camera/Hand/Weapon.transform.origin.y -= impact / 3000
# only play "ugh!" for certain force of impact
if impact >= 250:
$LandSFX.rpc(&"play")
# change volue based on impact force
$ImpactSFX.rpc(&"set_unit_db", min(-45 + (impact / 25), 0))
$ImpactSFX.rpc(&"play")
# if
# $Head/Camera/Hand/Weapon.transform.origin.y -= 0.25
#print("on floor now: ", is_on_floor(), " previously: ", previously_on_floor)
speed = speed_type[medium]
accel = accel_type[medium]
velocity = velocity.lerp(direction * speed, accel * delta)
previous_motion_velocity = motion_velocity
motion_velocity = velocity + gravity_vec
previously_on_floor = is_on_floor()
move_and_slide()
if not is_on_floor() and not ground_check.is_colliding(): # while in mid-air collisions affect momentum
@ -523,7 +540,7 @@ func _physics_process(delta):
velocity.z = motion_velocity.z
gravity_vec.y = motion_velocity.y
previously_on_floor = is_on_floor()
#lagging_movement_velocity.lerp(motion_velocity, delta)

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=44 format=3 uid="uid://cwuys43c7ak61"]
[gd_scene load_steps=46 format=3 uid="uid://cwuys43c7ak61"]
[ext_resource type="Script" path="res://Assets/Characters/Player.gd" id="1"]
[ext_resource type="AudioStream" uid="uid://cy80oknjqs5om" path="res://Assets/SFX/Wind.wav" id="2_4ifi7"]
@ -11,9 +11,11 @@
[ext_resource type="AudioStream" uid="uid://dnffb1xcdi2u5" path="res://Assets/SFX/Player_Pain_01.wav" id="6_a4nh8"]
[ext_resource type="AudioStream" uid="uid://dpxtkvkdj2ri3" path="res://Assets/SFX/Player_Jump_02.wav" id="6_s024f"]
[ext_resource type="AudioStream" uid="uid://gqypp5xk2ka7" path="res://Assets/SFX/Player_Pain_02.wav" id="7_0tfg5"]
[ext_resource type="Texture2D" uid="uid://w2koos4gq0r8" path="res://Assets/Effects/Busy.png" id="8_0hice"]
[ext_resource type="AudioStream" uid="uid://ddj28v4w4whkg" path="res://Assets/SFX/Player_Pain_03.wav" id="8_n5il5"]
[ext_resource type="AudioStream" uid="uid://xe0bppsq0wef" path="res://Assets/SFX/Player_Pain_04.wav" id="9_bobut"]
[ext_resource type="AudioStream" uid="uid://b2vgruyk0hae" path="res://Assets/SFX/Player_Land_01.wav" id="14_31oxc"]
[ext_resource type="Texture2D" uid="uid://bf7idsht43ljr" path="res://Assets/Effects/FocusMenu.png" id="14_54yom"]
[ext_resource type="AudioStream" uid="uid://dnd66qj5vjnvd" path="res://Assets/SFX/Player_Impact.wav" id="15_6s4ha"]
[sub_resource type="StandardMaterial3D" id="4"]
albedo_color = Color(0.545098, 0.545098, 0.545098, 1)
@ -227,7 +229,7 @@ tracks/0/keys = {
transparency = 1
no_depth_test = true
shading_mode = 0
albedo_texture = ExtResource( "8_0hice" )
albedo_texture = ExtResource( "14_54yom" )
disable_receive_shadows = true
billboard_mode = 1
point_size = 47.3
@ -392,6 +394,23 @@ attenuation_filter_db = -8.0
[node name="AudioStreamPlayer3D" parent="JumpSFX" index="0"]
stream = ExtResource( "6_s024f" )
unit_size = 10.0
[node name="LandSFX" parent="." instance=ExtResource( "5_yiom2" )]
[node name="AudioStreamPlayer3D" parent="LandSFX" index="0"]
stream = ExtResource( "14_31oxc" )
unit_size = 10.0
max_db = 0.0
autoplay = true
[node name="ImpactSFX" parent="." instance=ExtResource( "5_yiom2" )]
[node name="AudioStreamPlayer3D" parent="ImpactSFX" index="0"]
stream = ExtResource( "15_6s4ha" )
unit_size = 10.0
max_db = 0.0
autoplay = true
[node name="FocusBanner" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
@ -400,3 +419,5 @@ cast_shadow = 0
mesh = SubResource( "QuadMesh_nhjmb" )
[editable path="JumpSFX"]
[editable path="LandSFX"]
[editable path="ImpactSFX"]

BIN
Game/Assets/SFX/Player_Impact.wav (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,22 @@
[remap]
importer="wav"
type="AudioStreamSample"
uid="uid://dnd66qj5vjnvd"
path="res://.godot/imported/Player_Impact.wav-51550f51971e5b11ac00ae23762047f5.sample"
[deps]
source_file="res://Assets/SFX/Player_Impact.wav"
dest_files=["res://.godot/imported/Player_Impact.wav-51550f51971e5b11ac00ae23762047f5.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