Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sliding Sound #125

Merged
merged 8 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[remap]

importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://b7wmxwvtbpfu1"
path="res://.godot/imported/537275__laughingfish78__dirt-sliding.ogg-536e2ec4e654c17f52efb0f2a1a5b282.oggvorbisstr"

[deps]

source_file="res://COGITO/Assets/Audio/537275__laughingfish78__dirt-sliding.ogg"
dest_files=["res://.godot/imported/537275__laughingfish78__dirt-sliding.ogg-536e2ec4e654c17f52efb0f2a1a5b282.oggvorbisstr"]

[params]

loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
4 changes: 3 additions & 1 deletion COGITO/PrefabScenes/player.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=25 format=3 uid="uid://kicjwmh02uwf"]
[gd_scene load_steps=26 format=3 uid="uid://kicjwmh02uwf"]

[ext_resource type="Script" path="res://COGITO/Scripts/player.gd" id="1_wkneb"]
[ext_resource type="Resource" uid="uid://ev2xuamhfojm" path="res://COGITO/InventoryPD/Inventories/PlayerInventory.tres" id="2_qleua"]
Expand All @@ -17,6 +17,7 @@
[ext_resource type="PackedScene" uid="uid://cetc123v5gnff" path="res://COGITO/Components/Attributes/SanityAttribute.tscn" id="7_toa7v"]
[ext_resource type="AudioStream" uid="uid://b4mt1tuxo2144" path="res://COGITO/Assets/Audio/Kenney/Footsteps/footstep04.ogg" id="8_2tp8b"]
[ext_resource type="PackedScene" uid="uid://dxxemvynrimqw" path="res://COGITO/Wieldables/pickaxe.tscn" id="12_03s1j"]
[ext_resource type="AudioStream" uid="uid://b7wmxwvtbpfu1" path="res://COGITO/Assets/Audio/537275__laughingfish78__dirt-sliding.ogg" id="13_jr246"]
[ext_resource type="PackedScene" uid="uid://dy3tudla5p2nc" path="res://COGITO/Components/PlayerInteractionComponent.tscn" id="13_rawn6"]
[ext_resource type="Script" path="res://COGITO/DynamicFootstepSystem/Scripts/footstep_surface_detector.gd" id="16_a6uam"]
[ext_resource type="AudioStream" uid="uid://dc03jiw2a6y3j" path="res://COGITO/DynamicFootstepSystem/FootstepProfiles/generic_footstep_profile.tres" id="17_rmtvn"]
Expand Down Expand Up @@ -48,6 +49,7 @@ script = ExtResource("1_wkneb")
fall_damage = 10
inventory_data = ExtResource("2_qleua")
jump_sound = ExtResource("3_1sodd")
slide_sound = ExtResource("13_jr246")
HEADBOBBLE = 7
STEP_MAX_SLOPE_DEGREE = 1.0

Expand Down
54 changes: 38 additions & 16 deletions COGITO/Scripts/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,20 @@ var visibility_attribute : CogitoAttribute
@export_group("Audio")
## AudioStream that gets played when the player jumps.
@export var jump_sound : AudioStream
## AudioStream that gets played when the player slides (sprint + crouch).
@export var slide_sound : AudioStream
@export var walk_volume_db : float = -38.0
@export var sprint_volume_db : float = -30.0
@export var crouch_volume_db : float = -60.0
## the time between footstep sounds when walking
@export var walk_footstep_interval : float = 0.6
## the time between footstep sounds when sprinting
@export var sprint_footstep_interval : float = 0.3
## the speed at which the player must be moving before the footsteps change from walk to sprint.
@export var footstep_interval_change_velocity : float = 5.2

## performance saving variable
@onready var footstep_interval_change_velocity_square : float = footstep_interval_change_velocity * footstep_interval_change_velocity

@export_group("Movement Properties")
@export var JUMP_VELOCITY : float= 4.5
Expand Down Expand Up @@ -135,6 +146,7 @@ var last_velocity : Vector3= Vector3.ZERO
var stand_after_roll : bool = false
var is_movement_paused : bool = false
var is_dead : bool = false
var slide_audio_player : AudioStreamPlayer3D


func _ready():
Expand Down Expand Up @@ -181,6 +193,12 @@ func _ready():

initial_carryable_height = carryable_position.position.y #DEPRECATED

call_deferred("slide_audio_init")

func slide_audio_init():
#setup sound effect for sliding
slide_audio_player = Audio.play_sound_3d(slide_sound, false)
slide_audio_player.reparent(self, false)

# Use these functions to manipulate player attributes.
func increase_attribute(attribute_name: String, value: float, value_type: ConsumableItemPD.ValueType) -> bool:
Expand Down Expand Up @@ -739,22 +757,26 @@ func _physics_process(delta):
# FOOTSTEP SOUNDS SYSTEM = CHECK IF ON GROUND AND MOVING
if is_on_floor() and velocity.length() >= 0.2:
if not sliding_timer.is_stopped():
# TODO: Add slide sound effects. For now, mute it
pass
elif footstep_timer.time_left <= 0:
#dynamic volume for footsteps
if is_walking:
footstep_player.volume_db = walk_volume_db
elif is_crouching:
footstep_player.volume_db = crouch_volume_db
elif is_sprinting:
footstep_player.volume_db = sprint_volume_db
footstep_surface_detector.play_footstep()
# These "magic numbers" determine the frequency of sounds depending on speed of player. Need to make these variables.
if velocity.length() >= 3.4:
footstep_timer.start(.3)
else:
footstep_timer.start(.6)
if !slide_audio_player.playing:
slide_audio_player.play()

else:
slide_audio_player.stop()
if footstep_timer.time_left <= 0:
#dynamic volume for footsteps
if is_walking:
footstep_player.volume_db = walk_volume_db
elif is_crouching:
footstep_player.volume_db = crouch_volume_db
elif is_sprinting:
footstep_player.volume_db = sprint_volume_db
footstep_surface_detector.play_footstep()

#determine interval time between footsteps
if velocity.length_squared() >= footstep_interval_change_velocity_square:
footstep_timer.start(sprint_footstep_interval)
else:
footstep_timer.start(walk_footstep_interval)

func _on_sliding_timer_timeout():
is_free_looking = false
Expand Down