From e9424e2160d8217602e5ee7cb76b24b9d3b7cd3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobiasz=20Karo=C5=84?= Date: Sat, 19 Sep 2020 13:07:44 +0200 Subject: [PATCH] Implemented more SFX, implemented blood particle effects with sound. --- Assets/Effects/BodyHit.tscn | 7 ++++++- Assets/Weapons/Handgun/Handgun.tscn | 1 - Assets/Weapons/Weapon.gd | 2 +- Player.gd | 14 ++++++++++---- Player.tscn | 11 ++++++++++- default_bus_layout.tres | 3 +++ 6 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 default_bus_layout.tres diff --git a/Assets/Effects/BodyHit.tscn b/Assets/Effects/BodyHit.tscn index b631c5f..e1197e4 100644 --- a/Assets/Effects/BodyHit.tscn +++ b/Assets/Effects/BodyHit.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=22 format=2] +[gd_scene load_steps=23 format=2] [ext_resource path="res://Assets/Effects/CircleHard.svg" type="Texture" id=1] [ext_resource path="res://Assets/Effects/CircleSoft.svg" type="Texture" id=2] [ext_resource path="res://Assets/Effects/FreeTimer.gd" type="Script" id=3] +[ext_resource path="res://Audio/SoundPlayer.tscn" type="PackedScene" id=4] [sub_resource type="Animation" id=1] resource_name = "Effect" @@ -197,4 +198,8 @@ script = ExtResource( 3 ) __meta__ = { "_editor_description_": "Time to delete this scene." } + +[node name="SoundPlayer" parent="." instance=ExtResource( 4 )] +SoundClip = "res://Assets/SFX/Weapons-BulletHitPlayer-01.wav" +AutoPlay = true [connection signal="timeout" from="FreeTimer" to="FreeTimer" method="_on_FreeTimer_timeout"] diff --git a/Assets/Weapons/Handgun/Handgun.tscn b/Assets/Weapons/Handgun/Handgun.tscn index d88e298..cf77ecf 100644 --- a/Assets/Weapons/Handgun/Handgun.tscn +++ b/Assets/Weapons/Handgun/Handgun.tscn @@ -11,6 +11,5 @@ script = ExtResource( 2 ) [node name="SoundShoot" type="AudioStreamPlayer3D" parent="."] stream = ExtResource( 3 ) -unit_db = -12.0 [editable path="Handgun"] diff --git a/Assets/Weapons/Weapon.gd b/Assets/Weapons/Weapon.gd index 19b8859..63b69d9 100644 --- a/Assets/Weapons/Weapon.gd +++ b/Assets/Weapons/Weapon.gd @@ -45,6 +45,6 @@ remote func shoot(): $Handgun/AnimationPlayer.stop() $Handgun/AnimationPlayer.play("Shoot", -1, 2) - $SoundShoot.play(0) + $SoundShoot.play() diff --git a/Player.gd b/Player.gd index e72cdc1..dadbdf4 100644 --- a/Player.gd +++ b/Player.gd @@ -34,7 +34,8 @@ var velocity = Vector3.ZERO var walkDirection = Vector2.ZERO var walkDirInt = Vector2.ZERO -var bulletHitEffect = preload("res://Assets/Effects/BulletHit.tscn") +#var bulletHitEffect = preload("res://Assets/Effects/BulletHit.tscn") +var bodyHitEffect = preload("res://Assets/Effects/BodyHit.tscn") #func sfx_play_footsteps(): # if not sfx_footsteps_play: @@ -79,8 +80,8 @@ remote func walk(direction: Vector2): velocity.x = lerp(velocity.x, walkVelocity.rotated(- self.rotation.y).y, interpolation) velocity.z = lerp(velocity.z, - walkVelocity.rotated(- self.rotation.y).x, interpolation) -# if walkVelocity.length() > 0 and is_on_floor(): -# sfx_play_footsteps() + if walkVelocity.length() > 0 and is_on_floor(): + $Sounds/Footsteps.play() # remote func jump(): if is_on_floor(): @@ -142,9 +143,14 @@ master func on_hit(damage, location): if health <= 0: rpc("kill") + $Sounds/Death.play() + else: + $Sounds/Pain.play() remote func blood_splatter(location): - pass + var effect = bodyHitEffect.instance() + add_child(effect) + effect.global_transform.origin = location master func kill(): health = 0 diff --git a/Player.tscn b/Player.tscn index a53105b..ffb0619 100644 --- a/Player.tscn +++ b/Player.tscn @@ -57,7 +57,16 @@ __meta__ = { SoundClip = "res://Assets/SFX/Player-Jump-01.wav" [node name="Footsteps" parent="Sounds" instance=ExtResource( 7 )] -SoundClip = "res://Assets/SFX/Weapons-BulletFlyBy-01.wav" +SoundClip = "res://Assets/SFX/Player-Step-Concrete-01.wav" +PlayUntilEnd = true +MinDelay = 0.2 + +[node name="Death" parent="Sounds" instance=ExtResource( 7 )] +SoundClip = "res://Assets/SFX/Player-Death-01.wav" +MinDelay = 0.2 + +[node name="Pain" parent="Sounds" instance=ExtResource( 7 )] +SoundClip = "res://Assets/SFX/Player-Pain-01.wav" MinDelay = 0.2 [node name="CrosshairContainer" type="CenterContainer" parent="."] diff --git a/default_bus_layout.tres b/default_bus_layout.tres new file mode 100644 index 0000000..eb4accc --- /dev/null +++ b/default_bus_layout.tres @@ -0,0 +1,3 @@ +[gd_resource type="AudioBusLayout" format=2] + +[resource]