From e0759c00edfaedbd515c82cef8d997720fea601d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Balogh=20Kriszti=C3=A1n?= Date: Wed, 29 Jul 2026 02:37:45 +0200 Subject: [PATCH] added buggy breathing title says all. must fix some audio related bugs, and fix the breathing mechanic, so that the character breathes even when not staying still, but the breathing should sync to the camera bobbing --- scenes/player/movement_component.gd | 5 +- scenes/player/player.tscn | 205 +++++++++++++++--- scenes/player/player_manager.gd | 35 +-- .../procedural_camera_mover_component.gd | 17 +- scenes/player/sound_controller_component.gd | 173 ++++++++++++--- scenes/player/state_handler_component.gd | 35 +++ 6 files changed, 376 insertions(+), 94 deletions(-) diff --git a/scenes/player/movement_component.gd b/scenes/player/movement_component.gd index 33dab3b..48d429e 100644 --- a/scenes/player/movement_component.gd +++ b/scenes/player/movement_component.gd @@ -15,8 +15,6 @@ extends Node @export var CAMERA_VELOCITY_MULTIPLIER = 1.5 ##how heavy should the UI movement feel -var _mouse_motion: Vector2 = Vector2.ZERO - @onready var camera_pivot: Node3D = %CameraPivot @onready var player_camera: Camera3D = %PlayerCamera @onready var player: PlayerCharacter = $"../.." @@ -24,6 +22,8 @@ var _mouse_motion: Vector2 = Vector2.ZERO @onready var player_properties: Node = %PlayerProperties @onready var procedural_camera_mover: Node = %ProceduralCameraMover @onready var player_hit_box: CollisionShape3D = $"../../PlayerHitBox" +@onready var sound_controller: Node = %SoundController + # Called when the node enters the scene tree for the first time. func _ready() -> void: @@ -35,6 +35,7 @@ func _physics_process(delta: float) -> void: if not player_state.in_menu: if Input.is_action_just_pressed("jump") and player.is_on_floor() and player_properties.stamina > JUMP_STAMINA_COST: + sound_controller.play_jump_sound() player.velocity.y = JUMP_VELOCITY player_properties.stamina -= JUMP_STAMINA_COST player_properties.stamina_recharge_off() diff --git a/scenes/player/player.tscn b/scenes/player/player.tscn index 1224cde..d7f2246 100644 --- a/scenes/player/player.tscn +++ b/scenes/player/player.tscn @@ -66,9 +66,150 @@ [ext_resource type="Script" uid="uid://v8er7yn0hdh8" path="res://scenes/player/sound_controller_component.gd" id="62_b2j0d"] [ext_resource type="Script" uid="uid://y8x4svl5kej2" path="res://addons/spatial_audio_3d/spatial_audio_3d.gd" id="62_jbx34"] [ext_resource type="Script" uid="uid://7aa26wi66kqq" path="res://scenes/player/ui_handler_component.gd" id="63_7l6ig"] +[ext_resource type="AudioStream" uid="uid://m8l0dbbt7ijs" path="res://assets/sounds/walking/jump_landing/Jump-landing-001.wav" id="63_pkjeu"] +[ext_resource type="AudioStream" uid="uid://b5dxawp2qd8ps" path="res://assets/sounds/walking/jump_landing/Jump-landing-002.wav" id="64_0epl4"] [ext_resource type="Script" uid="uid://bvvwwkswavy5x" path="res://scenes/player/input_controller_component.gd" id="64_j3r50"] +[ext_resource type="AudioStream" uid="uid://c1wt8hmiv44oe" path="res://assets/sounds/walking/jump_landing/Jump-landing-003.wav" id="65_3r8w6"] [ext_resource type="Script" uid="uid://7hmwhf7acwpj" path="res://scenes/player/state_handler_component.gd" id="65_kssj8"] [ext_resource type="Script" uid="uid://cbdvyelf7nb1u" path="res://scenes/player/player_properties.gd" id="66_8lfxt"] +[ext_resource type="AudioStream" uid="uid://bv4npi51e2gww" path="res://assets/sounds/walking/jump_landing/Jump-landing-004.wav" id="66_i816j"] +[ext_resource type="AudioStream" uid="uid://cv4ojt7yvqtac" path="res://assets/sounds/walking/jump_landing/Jump-landing-005.wav" id="67_laqvq"] +[ext_resource type="AudioStream" uid="uid://wy8m1rr6delh" path="res://assets/sounds/walking/jump_landing/Jump-landing-006.wav" id="68_aq51r"] +[ext_resource type="AudioStream" uid="uid://26iqrpcn335f" path="res://assets/sounds/walking/jump_landing/Jump-landing-007.wav" id="69_q3ejk"] +[ext_resource type="AudioStream" uid="uid://du6cufwedemx6" path="res://assets/sounds/walking/jump_landing/Jump-landing-008.wav" id="70_2dxln"] +[ext_resource type="AudioStream" uid="uid://mb8r848krfcd" path="res://assets/sounds/walking/jump_landing/Jump-landing-009.wav" id="71_gsldg"] +[ext_resource type="AudioStream" uid="uid://6t8udlewh5po" path="res://assets/sounds/walking/jump_landing/Jump-landing-010.wav" id="72_rrrpt"] +[ext_resource type="AudioStream" uid="uid://2d1jvlj0qsfm" path="res://assets/sounds/walking/jump_landing/Jump-landing-011.wav" id="73_us45u"] +[ext_resource type="AudioStream" uid="uid://cvxbp8e5muvsi" path="res://assets/sounds/walking/jump_landing/Jump-landing-012.wav" id="74_wvv85"] +[ext_resource type="AudioStream" uid="uid://dmr7k5icpmbuj" path="res://assets/sounds/walking/jump_landing/Jump-landing-013.wav" id="75_hxu4r"] +[ext_resource type="AudioStream" uid="uid://ds1xgblkwfbbr" path="res://assets/sounds/walking/jump_starting/Jump-starting-001.wav" id="76_i6dto"] +[ext_resource type="AudioStream" uid="uid://dtd5vh23bin1q" path="res://assets/sounds/walking/jump_starting/Jump-starting-002.wav" id="77_4d8j4"] +[ext_resource type="AudioStream" uid="uid://cbyjyjrq3hyt8" path="res://assets/sounds/walking/jump_starting/Jump-starting-003.wav" id="78_s27sh"] +[ext_resource type="AudioStream" uid="uid://cro4b8arxnujq" path="res://assets/sounds/walking/jump_starting/Jump-starting-004.wav" id="79_1vi86"] +[ext_resource type="AudioStream" uid="uid://wwqh277vcf0s" path="res://assets/sounds/walking/jump_starting/Jump-starting-005.wav" id="80_beayq"] +[ext_resource type="AudioStream" uid="uid://drcu5bga2jkcs" path="res://assets/sounds/walking/jump_starting/Jump-starting-006.wav" id="81_12j61"] +[ext_resource type="AudioStream" uid="uid://bsvbvqhqrem76" path="res://assets/sounds/walking/jump_starting/Jump-starting-007.wav" id="82_kthys"] +[ext_resource type="AudioStream" uid="uid://doplej8ls8dm7" path="res://assets/sounds/walking/jump_starting/Jump-starting-008.wav" id="83_48o5h"] +[ext_resource type="AudioStream" uid="uid://cklsdk5055xmt" path="res://assets/sounds/walking/jump_starting/Jump-starting-009.wav" id="84_xum3i"] +[ext_resource type="AudioStream" uid="uid://cihklhhsqw8gv" path="res://assets/sounds/walking/jump_starting/Jump-starting-010.wav" id="85_ct4wv"] +[ext_resource type="AudioStream" uid="uid://dgoyg4wk6f0dq" path="res://assets/sounds/walking/jump_starting/Jump-starting-011.wav" id="86_teg5g"] +[ext_resource type="AudioStream" uid="uid://cm8pl8cmk3g6t" path="res://assets/sounds/walking/jump_starting/Jump-starting-012.wav" id="87_vcxk4"] +[ext_resource type="AudioStream" uid="uid://neoc2pa1syt4" path="res://assets/sounds/breathing/jump_landing/Jump-landing-breath-001.wav" id="88_x6bw1"] +[ext_resource type="AudioStream" uid="uid://8j7il8h57mah" path="res://assets/sounds/breathing/jump_landing/Jump-landing-breath-002.wav" id="89_e1bru"] +[ext_resource type="AudioStream" uid="uid://clf0pe72466c2" path="res://assets/sounds/breathing/jump_landing/Jump-landing-breath-003.wav" id="90_63x2c"] +[ext_resource type="AudioStream" uid="uid://cafdbjgdsx3sp" path="res://assets/sounds/breathing/jump_landing/Jump-landing-breath-004.wav" id="91_arxfr"] +[ext_resource type="AudioStream" uid="uid://dowbrvsjxkwb6" path="res://assets/sounds/breathing/jump_landing/Jump-landing-breath-005.wav" id="92_5ecds"] +[ext_resource type="AudioStream" uid="uid://dgfrrdq0i2ypm" path="res://assets/sounds/breathing/jump_landing/Jump-landing-breath-006.wav" id="93_nssm8"] +[ext_resource type="AudioStream" uid="uid://s1kgrff6yex5" path="res://assets/sounds/breathing/jump_landing/Jump-landing-breath-007.wav" id="94_ei0bd"] +[ext_resource type="AudioStream" uid="uid://c8wxsbm4tcg7u" path="res://assets/sounds/breathing/jump_landing/Jump-landing-breath-008.wav" id="95_wwa77"] +[ext_resource type="AudioStream" uid="uid://dq6dxohfpwxbe" path="res://assets/sounds/breathing/jump_landing/Jump-landing-breath-009.wav" id="96_tdwly"] +[ext_resource type="AudioStream" uid="uid://c8jctl7rnt2be" path="res://assets/sounds/breathing/jump_starting/Jump-starting-breath-001.wav" id="97_fmlco"] +[ext_resource type="AudioStream" uid="uid://ygcl230au0p6" path="res://assets/sounds/breathing/jump_starting/Jump-starting-breath-002.wav" id="98_duoik"] +[ext_resource type="AudioStream" uid="uid://dea8ndg1asyk" path="res://assets/sounds/breathing/jump_starting/Jump-starting-breath-003.wav" id="99_6qclm"] +[ext_resource type="AudioStream" uid="uid://bpsnlo1kacuo0" path="res://assets/sounds/breathing/jump_starting/Jump-starting-breath-004.wav" id="100_mtkxs"] +[ext_resource type="AudioStream" uid="uid://btrjiosx6bsuj" path="res://assets/sounds/breathing/jump_starting/Jump-starting-breath-005.wav" id="101_pxyg8"] +[ext_resource type="AudioStream" uid="uid://c3ehcborefxxh" path="res://assets/sounds/breathing/jump_starting/Jump-starting-breath-006.wav" id="102_xm1em"] +[ext_resource type="AudioStream" uid="uid://w66w8tfhw8d5" path="res://assets/sounds/breathing/jump_starting/Jump-starting-breath-007.wav" id="103_6ix8p"] +[ext_resource type="AudioStream" uid="uid://djtweftr6pqq6" path="res://assets/sounds/breathing/jump_starting/Jump-starting-breath-008.wav" id="104_fntve"] +[ext_resource type="AudioStream" uid="uid://068u3u51j1mr" path="res://assets/sounds/breathing/jump_starting/Jump-starting-breath-009.wav" id="105_a2vma"] +[ext_resource type="AudioStream" uid="uid://18hrvhk3i5ay" path="res://assets/sounds/breathing/jump_starting/Jump-starting-breath-010.wav" id="106_b63cp"] +[ext_resource type="AudioStream" uid="uid://dhtudndpsy06f" path="res://assets/sounds/breathing/jump_starting/Jump-starting-breath-011.wav" id="107_l2ov3"] +[ext_resource type="AudioStream" uid="uid://ckff6hj147vel" path="res://assets/sounds/breathing/breathe_in/breathe_in_calm/Breathe-in-calm-001.mp3" id="108_76ube"] +[ext_resource type="AudioStream" uid="uid://br8wnwv76bdxw" path="res://assets/sounds/breathing/breathe_in/breathe_in_calm/Breathe-in-calm-002.mp3" id="109_agxve"] +[ext_resource type="AudioStream" uid="uid://bxjuiklnicjas" path="res://assets/sounds/breathing/breathe_in/breathe_in_calm/Breathe-in-calm-003.mp3" id="110_8ue2q"] +[ext_resource type="AudioStream" uid="uid://lc51pt12tqoa" path="res://assets/sounds/breathing/breathe_in/breathe_in_calm/Breathe-in-calm-004.mp3" id="111_p0pgs"] +[ext_resource type="AudioStream" uid="uid://du2h647hymjxb" path="res://assets/sounds/breathing/breathe_in/breathe_in_calm/Breathe-in-calm-005.mp3" id="112_uru8s"] +[ext_resource type="AudioStream" uid="uid://bcdtnx6gcuh5" path="res://assets/sounds/breathing/breathe_in/breathe_in_low/Breathe-in-low-001.mp3" id="113_mqtqs"] +[ext_resource type="AudioStream" uid="uid://d1r4ybjwmqxsw" path="res://assets/sounds/breathing/breathe_in/breathe_in_low/Breathe-in-low-002.mp3" id="114_mje2k"] +[ext_resource type="AudioStream" uid="uid://cx6eiff56ww2a" path="res://assets/sounds/breathing/breathe_in/breathe_in_low/Breathe-in-low-003.mp3" id="115_c0t4m"] +[ext_resource type="AudioStream" uid="uid://5okgfhekv4l6" path="res://assets/sounds/breathing/breathe_in/breathe_in_low/Breathe-in-low-004.mp3" id="116_axrhj"] +[ext_resource type="AudioStream" uid="uid://b8imcfuqa228f" path="res://assets/sounds/breathing/breathe_in/breathe_in_low/Breathe-in-low-005.mp3" id="117_14dna"] +[ext_resource type="AudioStream" uid="uid://hom1n0yqdqhl" path="res://assets/sounds/breathing/breathe_in/breathe_in_mid/Breathe-in-mid-001.mp3" id="118_dtvgl"] +[ext_resource type="AudioStream" uid="uid://clxgeypjw0cnu" path="res://assets/sounds/breathing/breathe_in/breathe_in_mid/Breathe-in-mid-002.mp3" id="119_oa6rg"] +[ext_resource type="AudioStream" uid="uid://c2wdahp1wyaj3" path="res://assets/sounds/breathing/breathe_in/breathe_in_mid/Breathe-in-mid-003.mp3" id="120_qnksm"] +[ext_resource type="AudioStream" uid="uid://h7s43su7guj4" path="res://assets/sounds/breathing/breathe_in/breathe_in_mid/Breathe-in-mid-004.mp3" id="121_u6low"] +[ext_resource type="AudioStream" uid="uid://bp0vntm8alsu6" path="res://assets/sounds/breathing/breathe_in/breathe_in_mid/Breathe-in-mid-005.mp3" id="122_lqiud"] +[ext_resource type="AudioStream" uid="uid://53excusm7nmr" path="res://assets/sounds/breathing/breathe_in/breathe_in_mid/Breathe-in-mid-006.mp3" id="123_m1x1w"] +[ext_resource type="AudioStream" uid="uid://c1s3pij2eo8yi" path="res://assets/sounds/breathing/breathe_in/breathe_in_mid/Breathe-in-mid-007.mp3" id="124_pewko"] +[ext_resource type="AudioStream" uid="uid://dyv485tit88uy" path="res://assets/sounds/breathing/breathe_in/breathe_in_mid/Breathe-in-mid-008.mp3" id="125_oq118"] +[ext_resource type="AudioStream" uid="uid://cnowvw3l2xh5o" path="res://assets/sounds/breathing/breathe_in/breathe_in_mid/Breathe-in-mid-009.mp3" id="126_cw82d"] +[ext_resource type="AudioStream" uid="uid://dl5swalfuq3ju" path="res://assets/sounds/breathing/breathe_in/breathe_in_heavy/Breathe-in-heavy-001.mp3" id="127_g11hh"] +[ext_resource type="AudioStream" uid="uid://dvjajoo73m2m0" path="res://assets/sounds/breathing/breathe_in/breathe_in_heavy/Breathe-in-heavy-002.mp3" id="128_mcl3m"] +[ext_resource type="AudioStream" uid="uid://cojxamnp2jgbq" path="res://assets/sounds/breathing/breathe_in/breathe_in_heavy/Breathe-in-heavy-003.mp3" id="129_s46af"] +[ext_resource type="AudioStream" uid="uid://fl5f6vyomtgw" path="res://assets/sounds/breathing/breathe_in/breathe_in_heavy/Breathe-in-heavy-004.mp3" id="130_rpy06"] +[ext_resource type="AudioStream" uid="uid://b13ec1itp5m1f" path="res://assets/sounds/breathing/breathe_in/breathe_in_heavy/Breathe-in-heavy-005.mp3" id="131_f4fcx"] +[ext_resource type="AudioStream" uid="uid://cd3ioy8cev6o2" path="res://assets/sounds/breathing/breathe_in/breathe_in_heavy/Breathe-in-heavy-006.mp3" id="132_auu8a"] +[ext_resource type="AudioStream" uid="uid://bdycd08rs5lto" path="res://assets/sounds/breathing/breathe_in/breathe_in_heavy/Breathe-in-heavy-007.mp3" id="133_lkwya"] +[ext_resource type="AudioStream" uid="uid://bvip6wkxnje7k" path="res://assets/sounds/breathing/breathe_in/breathe_in_heavy/Breathe-in-heavy-008.mp3" id="134_et857"] +[ext_resource type="AudioStream" uid="uid://c6lskxqw74giq" path="res://assets/sounds/breathing/breathe_in/breathe_in_heavy/Breathe-in-heavy-009.mp3" id="135_7yw2v"] +[ext_resource type="AudioStream" uid="uid://d3icuggu6j03f" path="res://assets/sounds/breathing/breathe_in/breathe_in_heavy/Breathe-in-heavy-010.mp3" id="136_eb5ts"] +[ext_resource type="AudioStream" uid="uid://xsxqu5t0p1db" path="res://assets/sounds/breathing/breathe_in/breathe_in_max/Breathe-in-max-001.mp3" id="137_ui8rx"] +[ext_resource type="AudioStream" uid="uid://d3detm67ixuab" path="res://assets/sounds/breathing/breathe_in/breathe_in_max/Breathe-in-max-002.mp3" id="138_fild8"] +[ext_resource type="AudioStream" uid="uid://bbgnw8bvwko1l" path="res://assets/sounds/breathing/breathe_in/breathe_in_max/Breathe-in-max-003.mp3" id="139_oyq3u"] +[ext_resource type="AudioStream" uid="uid://qvwvaolik7w4" path="res://assets/sounds/breathing/breathe_in/breathe_in_max/Breathe-in-max-004.mp3" id="140_q53ni"] +[ext_resource type="AudioStream" uid="uid://cbmqas7bomxd6" path="res://assets/sounds/breathing/breathe_in/breathe_in_max/Breathe-in-max-005.mp3" id="141_4v6xr"] +[ext_resource type="AudioStream" uid="uid://bp2bqy7li7fhe" path="res://assets/sounds/breathing/breathe_in/breathe_in_max/Breathe-in-max-006.mp3" id="142_o8ce2"] +[ext_resource type="AudioStream" uid="uid://do345lm7e30my" path="res://assets/sounds/breathing/breathe_in/breathe_in_exhausted/Breathe-in-exhausted-001.mp3" id="143_s6fkf"] +[ext_resource type="AudioStream" uid="uid://c7phfwf26bby2" path="res://assets/sounds/breathing/breathe_in/breathe_in_exhausted/Breathe-in-exhausted-002.mp3" id="144_7kgw3"] +[ext_resource type="AudioStream" uid="uid://dysxdat6c51fl" path="res://assets/sounds/breathing/breathe_in/breathe_in_exhausted/Breathe-in-exhausted-003.mp3" id="145_mu3ts"] +[ext_resource type="AudioStream" uid="uid://cxn86pp58r0vn" path="res://assets/sounds/breathing/breathe_in/breathe_in_exhausted/Breathe-in-exhausted-004.mp3" id="146_ewv0n"] +[ext_resource type="AudioStream" uid="uid://bu50pqieqh0b3" path="res://assets/sounds/breathing/breathe_in/breathe_in_exhausted/Breathe-in-exhausted-005.mp3" id="147_lbifn"] +[ext_resource type="AudioStream" uid="uid://bce34osfwdmqx" path="res://assets/sounds/breathing/breathe_in/breathe_in_exhausted/Breathe-in-exhausted-006.mp3" id="148_rm8dy"] +[ext_resource type="AudioStream" uid="uid://bn3cpslh1wofv" path="res://assets/sounds/breathing/breathe_in/breathe_in_exhausted/Breathe-in-exhausted-007.mp3" id="149_f8aoj"] +[ext_resource type="AudioStream" uid="uid://gapq7qgi2snm" path="res://assets/sounds/breathing/breathe_in/breathe_in_exhausted/Breathe-in-exhausted-008.mp3" id="150_s2tgi"] +[ext_resource type="AudioStream" uid="uid://b7r17q7iskrxj" path="res://assets/sounds/breathing/breathe_in/breathe_in_exhausted/Breathe-in-exhausted-009.mp3" id="151_il3lm"] +[ext_resource type="AudioStream" uid="uid://dau2i3g34nngy" path="res://assets/sounds/breathing/breathe_in/breathe_in_exhausted/Breathe-in-exhausted-010.mp3" id="152_gdkqs"] +[ext_resource type="AudioStream" uid="uid://dcwbtf8cj76a6" path="res://assets/sounds/breathing/breathe_in/breathe_in_exhausted/Breathe-in-exhausted-011.mp3" id="153_utlgu"] +[ext_resource type="AudioStream" uid="uid://di8gmywgwug23" path="res://assets/sounds/breathing/breathe_in/breathe_in_exhausted/Breathe-in-exhausted-012.mp3" id="154_w3io3"] +[ext_resource type="AudioStream" uid="uid://df1p8i0run5rb" path="res://assets/sounds/breathing/breathe_out/breathe_out_calm/Breathe-out-calm-002.mp3" id="156_hgc6s"] +[ext_resource type="AudioStream" uid="uid://d0julp7xqyr5n" path="res://assets/sounds/breathing/breathe_out/breathe_out_calm/Breathe-out-calm-003.mp3" id="157_6m11j"] +[ext_resource type="AudioStream" uid="uid://bleld3ult64go" path="res://assets/sounds/breathing/breathe_out/breathe_out_calm/Breathe-out-calm-004.mp3" id="158_mfbti"] +[ext_resource type="AudioStream" uid="uid://dm7aok7jhnv4" path="res://assets/sounds/breathing/breathe_out/breathe_out_calm/Breathe-out-calm-005.mp3" id="159_rekon"] +[ext_resource type="AudioStream" uid="uid://bb734uxmqcr8u" path="res://assets/sounds/breathing/breathe_out/breathe_out_calm/Breathe-out-calm-006.mp3" id="160_tol08"] +[ext_resource type="AudioStream" uid="uid://qj85gkjwlswl" path="res://assets/sounds/breathing/breathe_out/breathe_out_calm/Breathe-out-calm-007.mp3" id="161_5ghxp"] +[ext_resource type="AudioStream" uid="uid://ctysfxkteyols" path="res://assets/sounds/breathing/breathe_out/breathe_out_low/Breathe-out-low-001.mp3" id="162_n54tq"] +[ext_resource type="AudioStream" uid="uid://drjrhsgm7sx3n" path="res://assets/sounds/breathing/breathe_out/breathe_out_low/Breathe-out-low-002.mp3" id="163_3fiag"] +[ext_resource type="AudioStream" uid="uid://d0eyxdccg0m8v" path="res://assets/sounds/breathing/breathe_out/breathe_out_low/Breathe-out-low-003.mp3" id="164_elpd3"] +[ext_resource type="AudioStream" uid="uid://dgsxkkyl0twyv" path="res://assets/sounds/breathing/breathe_out/breathe_out_low/Breathe-out-low-004.mp3" id="165_4q6hw"] +[ext_resource type="AudioStream" uid="uid://bqt3kfmoav03b" path="res://assets/sounds/breathing/breathe_out/breathe_out_mid/Breathe-out-mid-001.mp3" id="166_2qmd4"] +[ext_resource type="AudioStream" uid="uid://cnmcge2om4782" path="res://assets/sounds/breathing/breathe_out/breathe_out_mid/Breathe-out-mid-002.mp3" id="167_h0ugi"] +[ext_resource type="AudioStream" uid="uid://cns438dqcip7" path="res://assets/sounds/breathing/breathe_out/breathe_out_mid/Breathe-out-mid-003.mp3" id="168_afk8h"] +[ext_resource type="AudioStream" uid="uid://b6t4hqi0pupvk" path="res://assets/sounds/breathing/breathe_out/breathe_out_mid/Breathe-out-mid-004.mp3" id="169_1wu6y"] +[ext_resource type="AudioStream" uid="uid://5a21wbtn5cga" path="res://assets/sounds/breathing/breathe_out/breathe_out_mid/Breathe-out-mid-005.mp3" id="170_yfygc"] +[ext_resource type="AudioStream" uid="uid://dqkpx7nayisf" path="res://assets/sounds/breathing/breathe_out/breathe_out_mid/Breathe-out-mid-006.mp3" id="171_sf660"] +[ext_resource type="AudioStream" uid="uid://qpg6rx01c21k" path="res://assets/sounds/breathing/breathe_out/breathe_out_mid/Breathe-out-mid-007.mp3" id="172_7ijij"] +[ext_resource type="AudioStream" uid="uid://cstmv5ve8nufu" path="res://assets/sounds/breathing/breathe_out/breathe_out_mid/Breathe-out-mid-008.mp3" id="173_kjnhu"] +[ext_resource type="AudioStream" uid="uid://150bt0xtbgfa" path="res://assets/sounds/breathing/breathe_out/breathe_out_mid/Breathe-out-mid-009.mp3" id="174_m8hjx"] +[ext_resource type="AudioStream" uid="uid://cdrw7vscc0xdp" path="res://assets/sounds/breathing/breathe_out/breathe_out_mid/Breathe-out-mid-010.mp3" id="175_skt8w"] +[ext_resource type="AudioStream" uid="uid://ca2as7g6td2wj" path="res://assets/sounds/breathing/breathe_out/breathe_out_heavy/Breathe-out-heavy-001.mp3" id="176_xb8ft"] +[ext_resource type="AudioStream" uid="uid://d2c8ycx38ot1f" path="res://assets/sounds/breathing/breathe_out/breathe_out_heavy/Breathe-out-heavy-002.mp3" id="177_mro88"] +[ext_resource type="AudioStream" uid="uid://bswsj6q1vco62" path="res://assets/sounds/breathing/breathe_out/breathe_out_heavy/Breathe-out-heavy-003.mp3" id="178_ya4ln"] +[ext_resource type="AudioStream" uid="uid://bwfaqqq6hpy4" path="res://assets/sounds/breathing/breathe_out/breathe_out_heavy/Breathe-out-heavy-004.mp3" id="179_yopjo"] +[ext_resource type="AudioStream" uid="uid://cud6dpvq3qf61" path="res://assets/sounds/breathing/breathe_out/breathe_out_heavy/Breathe-out-heavy-005.mp3" id="180_wtqmm"] +[ext_resource type="AudioStream" uid="uid://ckwbj0jo734jb" path="res://assets/sounds/breathing/breathe_out/breathe_out_heavy/Breathe-out-heavy-006.mp3" id="181_7cqnf"] +[ext_resource type="AudioStream" uid="uid://cuy7xs0odtm08" path="res://assets/sounds/breathing/breathe_out/breathe_out_heavy/Breathe-out-heavy-007.mp3" id="182_q07wn"] +[ext_resource type="AudioStream" uid="uid://ysa23wix0xrk" path="res://assets/sounds/breathing/breathe_out/breathe_out_heavy/Breathe-out-heavy-008.mp3" id="183_72ejc"] +[ext_resource type="AudioStream" uid="uid://dtxgfj8eq5l31" path="res://assets/sounds/breathing/breathe_out/breathe_out_heavy/Breathe-out-heavy-009.mp3" id="184_m1gsv"] +[ext_resource type="AudioStream" uid="uid://dbx6bj01mb7l1" path="res://assets/sounds/breathing/breathe_out/breathe_out_heavy/Breathe-out-heavy-010.mp3" id="185_2yvq7"] +[ext_resource type="AudioStream" uid="uid://ds3glu4nqhdbh" path="res://assets/sounds/breathing/breathe_out/breathe_out_max/Breathe-out-max-001.mp3" id="186_7qaaa"] +[ext_resource type="AudioStream" uid="uid://bajagb8gdrorr" path="res://assets/sounds/breathing/breathe_out/breathe_out_max/Breathe-out-max-002.mp3" id="187_yoiq4"] +[ext_resource type="AudioStream" uid="uid://dnve10ipdw44l" path="res://assets/sounds/breathing/breathe_out/breathe_out_max/Breathe-out-max-003.mp3" id="188_4anq4"] +[ext_resource type="AudioStream" uid="uid://d3mmjb1sspbro" path="res://assets/sounds/breathing/breathe_out/breathe_out_max/Breathe-out-max-004.mp3" id="189_mkwaq"] +[ext_resource type="AudioStream" uid="uid://bp4rmahq4wpkp" path="res://assets/sounds/breathing/breathe_out/breathe_out_max/Breathe-out-max-005.mp3" id="190_0falv"] +[ext_resource type="AudioStream" uid="uid://c5sjq0em24hb1" path="res://assets/sounds/breathing/breathe_out/breathe_out_max/Breathe-out-max-006.mp3" id="191_wvqjg"] +[ext_resource type="AudioStream" uid="uid://bv4xhgwylcxfg" path="res://assets/sounds/breathing/breathe_out/breathe_out_max/Breathe-out-max-007.mp3" id="192_xwj34"] +[ext_resource type="AudioStream" uid="uid://4fgsklkfb0yp" path="res://assets/sounds/breathing/breathe_out/breathe_out_exhausted/Breathe-out-exhausted-001.mp3" id="193_2ggvy"] +[ext_resource type="AudioStream" uid="uid://c5wc8id1qc6yn" path="res://assets/sounds/breathing/breathe_out/breathe_out_exhausted/Breathe-out-exhausted-002.mp3" id="194_hvgvr"] +[ext_resource type="AudioStream" uid="uid://8v015hgrewud" path="res://assets/sounds/breathing/breathe_out/breathe_out_exhausted/Breathe-out-exhausted-003.mp3" id="195_c63qf"] +[ext_resource type="AudioStream" uid="uid://bn3wdx3vc6un7" path="res://assets/sounds/breathing/breathe_out/breathe_out_exhausted/Breathe-out-exhausted-004.mp3" id="196_nqymb"] +[ext_resource type="AudioStream" uid="uid://dds4em4a5bbtb" path="res://assets/sounds/breathing/breathe_out/breathe_out_exhausted/Breathe-out-exhausted-005.mp3" id="197_n2wjg"] +[ext_resource type="AudioStream" uid="uid://cgpkael8dcffr" path="res://assets/sounds/breathing/breathe_out/breathe_out_exhausted/Breathe-out-exhausted-006.mp3" id="198_vh6pe"] +[ext_resource type="AudioStream" uid="uid://dtg6sp12wi7h2" path="res://assets/sounds/breathing/breathe_out/breathe_out_exhausted/Breathe-out-exhausted-007.mp3" id="199_0b2jo"] +[ext_resource type="AudioStream" uid="uid://ofhlbc8ywo2i" path="res://assets/sounds/breathing/breathe_out/breathe_out_exhausted/Breathe-out-exhausted-008.mp3" id="200_4ttds"] +[ext_resource type="AudioStream" uid="uid://c8sksdmrqxcs1" path="res://assets/sounds/breathing/breathe_out/breathe_out_exhausted/Breathe-out-exhausted-009.mp3" id="201_8ri8i"] +[ext_resource type="AudioStream" uid="uid://c1h0kurf2ly1k" path="res://assets/sounds/breathing/breathe_out/breathe_out_exhausted/Breathe-out-exhausted-010.mp3" id="202_vlfn3"] +[ext_resource type="AudioStream" uid="uid://dkj34tqoqppml" path="res://assets/sounds/breathing/breathe_out/breathe_out_exhausted/Breathe-out-exhausted-011.mp3" id="203_klwgm"] +[ext_resource type="AudioStream" uid="uid://bwsj7yir6tced" path="res://assets/sounds/breathing/breathe_out/breathe_out_exhausted/Breathe-out-exhausted-012.mp3" id="204_xfldr"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_g4v7s"] @@ -119,8 +260,24 @@ script = ExtResource("62_b2j0d") NORMAL_FOOTSTEP_SOUNDS = Array[AudioStreamWAV]([ExtResource("2_32hag"), ExtResource("3_tqiix"), ExtResource("4_e7oew"), ExtResource("5_c35mf"), ExtResource("6_65viv"), ExtResource("7_x7c3f"), ExtResource("8_bjvpn"), ExtResource("9_s7qer"), ExtResource("10_g4c7l"), ExtResource("11_knn7v"), ExtResource("12_7pqkx"), ExtResource("13_uw77l"), ExtResource("14_rptt4")]) HEAVY_FOOTSTEP_SOUNDS = Array[AudioStreamWAV]([ExtResource("15_n0b8q"), ExtResource("16_jfgyi"), ExtResource("17_237xx"), ExtResource("18_wpyo2"), ExtResource("19_7crtr"), ExtResource("20_vgvch"), ExtResource("21_a1u5o"), ExtResource("22_3dxkp"), ExtResource("23_6wior"), ExtResource("24_p5tca"), ExtResource("25_jbx34"), ExtResource("26_s3g0c"), ExtResource("27_35wys"), ExtResource("28_pjwc4"), ExtResource("29_or4qq"), ExtResource("30_hggc2")]) LIGHT_FOOTSTEP_SOUNDS = Array[AudioStreamWAV]([ExtResource("31_b2j0d"), ExtResource("32_7l6ig"), ExtResource("33_j3r50"), ExtResource("34_utr5e"), ExtResource("35_kewli"), ExtResource("36_do7qw"), ExtResource("37_2h6tc"), ExtResource("38_8rogd"), ExtResource("39_48p26"), ExtResource("40_anp34"), ExtResource("41_jdjat"), ExtResource("42_j420s"), ExtResource("43_kcq4v")]) -SHUFFLE_FOOTSTEP_SOUNDS = Array[AudioStreamWAV]([ExtResource("44_qavcc"), ExtResource("45_bd26m"), ExtResource("46_lufic"), ExtResource("47_nxclr"), ExtResource("48_onxu2"), ExtResource("49_gci7n"), ExtResource("50_tcwf7")]) FLASHLIGHT_CLICK_SOUNDS = Array[AudioStreamWAV]([ExtResource("51_pjwc4"), ExtResource("52_or4qq"), ExtResource("53_hggc2"), ExtResource("55_7l6ig"), ExtResource("56_j3r50"), ExtResource("59_do7qw"), ExtResource("61_8rogd"), ExtResource("62_48p26")]) +SHUFFLE_FOOTSTEP_SOUNDS = Array[AudioStreamWAV]([ExtResource("44_qavcc"), ExtResource("45_bd26m"), ExtResource("46_lufic"), ExtResource("47_nxclr"), ExtResource("48_onxu2"), ExtResource("49_gci7n"), ExtResource("50_tcwf7")]) +JUMP_LANDING_SOUNDS = Array[AudioStream]([ExtResource("63_pkjeu"), ExtResource("64_0epl4"), ExtResource("65_3r8w6"), ExtResource("66_i816j"), ExtResource("67_laqvq"), ExtResource("68_aq51r"), ExtResource("69_q3ejk"), ExtResource("70_2dxln"), ExtResource("71_gsldg"), ExtResource("72_rrrpt"), ExtResource("73_us45u"), ExtResource("74_wvv85"), ExtResource("75_hxu4r")]) +JUMP_STARTING_SOUNDS = Array[AudioStream]([ExtResource("76_i6dto"), ExtResource("77_4d8j4"), ExtResource("78_s27sh"), ExtResource("79_1vi86"), ExtResource("80_beayq"), ExtResource("81_12j61"), ExtResource("82_kthys"), ExtResource("83_48o5h"), ExtResource("84_xum3i"), ExtResource("85_ct4wv"), ExtResource("86_teg5g"), ExtResource("87_vcxk4")]) +JUMP_LANDING_BREATH_SOUNDS = Array[AudioStream]([ExtResource("88_x6bw1"), ExtResource("89_e1bru"), ExtResource("90_63x2c"), ExtResource("91_arxfr"), ExtResource("92_5ecds"), ExtResource("93_nssm8"), ExtResource("94_ei0bd"), ExtResource("95_wwa77"), ExtResource("96_tdwly")]) +JUMP_STARTING_BREATH_SOUNDS = Array[AudioStream]([ExtResource("97_fmlco"), ExtResource("98_duoik"), ExtResource("99_6qclm"), ExtResource("100_mtkxs"), ExtResource("101_pxyg8"), ExtResource("102_xm1em"), ExtResource("103_6ix8p"), ExtResource("104_fntve"), ExtResource("105_a2vma"), ExtResource("106_b63cp"), ExtResource("107_l2ov3")]) +BREATHE_IN_CALM = Array[AudioStream]([ExtResource("108_76ube"), ExtResource("109_agxve"), ExtResource("110_8ue2q"), ExtResource("111_p0pgs"), ExtResource("112_uru8s")]) +BREATHE_IN_LOW = Array[AudioStream]([ExtResource("113_mqtqs"), ExtResource("114_mje2k"), ExtResource("115_c0t4m"), ExtResource("116_axrhj"), ExtResource("117_14dna")]) +BREATHE_IN_MID = Array[AudioStream]([ExtResource("118_dtvgl"), ExtResource("119_oa6rg"), ExtResource("120_qnksm"), ExtResource("121_u6low"), ExtResource("122_lqiud"), ExtResource("123_m1x1w"), ExtResource("124_pewko"), ExtResource("125_oq118"), ExtResource("126_cw82d")]) +BREATHE_IN_HEAVY = Array[AudioStream]([ExtResource("127_g11hh"), ExtResource("128_mcl3m"), ExtResource("129_s46af"), ExtResource("130_rpy06"), ExtResource("131_f4fcx"), ExtResource("132_auu8a"), ExtResource("133_lkwya"), ExtResource("134_et857"), ExtResource("135_7yw2v"), ExtResource("136_eb5ts")]) +BREATHE_IN_MAX = Array[AudioStream]([ExtResource("137_ui8rx"), ExtResource("138_fild8"), ExtResource("139_oyq3u"), ExtResource("140_q53ni"), ExtResource("141_4v6xr"), ExtResource("142_o8ce2")]) +BREATHE_IN_EXHAUSTED = Array[AudioStream]([ExtResource("143_s6fkf"), ExtResource("144_7kgw3"), ExtResource("145_mu3ts"), ExtResource("146_ewv0n"), ExtResource("147_lbifn"), ExtResource("148_rm8dy"), ExtResource("149_f8aoj"), ExtResource("150_s2tgi"), ExtResource("151_il3lm"), ExtResource("152_gdkqs"), ExtResource("153_utlgu"), ExtResource("154_w3io3")]) +BREATHE_OUT_CALM = Array[AudioStream]([ExtResource("156_hgc6s"), ExtResource("157_6m11j"), ExtResource("158_mfbti"), ExtResource("159_rekon"), ExtResource("160_tol08"), ExtResource("161_5ghxp")]) +BREATHE_OUT_LOW = Array[AudioStream]([ExtResource("162_n54tq"), ExtResource("163_3fiag"), ExtResource("164_elpd3"), ExtResource("165_4q6hw")]) +BREATHE_OUT_MID = Array[AudioStream]([ExtResource("166_2qmd4"), ExtResource("167_h0ugi"), ExtResource("168_afk8h"), ExtResource("169_1wu6y"), ExtResource("170_yfygc"), ExtResource("171_sf660"), ExtResource("172_7ijij"), ExtResource("173_kjnhu"), ExtResource("174_m8hjx"), ExtResource("175_skt8w")]) +BREATHE_OUT_HEAVY = Array[AudioStream]([ExtResource("176_xb8ft"), ExtResource("177_mro88"), ExtResource("178_ya4ln"), ExtResource("179_yopjo"), ExtResource("180_wtqmm"), ExtResource("181_7cqnf"), ExtResource("182_q07wn"), ExtResource("183_72ejc"), ExtResource("184_m1gsv"), ExtResource("185_2yvq7")]) +BREATHE_OUT_MAX = Array[AudioStream]([ExtResource("186_7qaaa"), ExtResource("187_yoiq4"), ExtResource("188_4anq4"), ExtResource("189_mkwaq"), ExtResource("190_0falv"), ExtResource("191_wvqjg"), ExtResource("192_xwj34")]) +BREATHE_OUT_EXHAUSTED = Array[AudioStream]([ExtResource("193_2ggvy"), ExtResource("194_hvgvr"), ExtResource("195_c63qf"), ExtResource("196_nqymb"), ExtResource("197_n2wjg"), ExtResource("198_vh6pe"), ExtResource("199_0b2jo"), ExtResource("200_4ttds"), ExtResource("201_8ri8i"), ExtResource("202_vlfn3"), ExtResource("203_klwgm"), ExtResource("204_xfldr")]) [node name="UiHandler" type="Node" parent="Components" unique_id=1264775993] unique_name_in_owner = true @@ -217,75 +374,63 @@ expand_mode = 1 [node name="StaminaReset" type="Timer" parent="." unique_id=1815815085] unique_name_in_owner = true -wait_time = 2.0 +wait_time = 5.214 one_shot = true [node name="SoundEmitters" type="Node3D" parent="." unique_id=661429541] -[node name="LeftFoot" type="AudioStreamPlayer3D" parent="SoundEmitters" unique_id=49863314] +[node name="LeftFoot" type="AudioStreamPlayer3D" parent="SoundEmitters" unique_id=575461780] unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.43042383, -0.90646136, 0) -area_mask = 17 -doppler_tracking = 2 script = ExtResource("62_jbx34") +reverb_enabled = false reverb_volume_db = -12.0 reverb_fadeintime = -1.0 reverb_fadeouttime = -1.0 -bass_proximity = 0 -max_raycast_distance = 200 -roomsize_multiplicator = 20.0 metadata/_custom_type_script = "uid://y8x4svl5kej2" -[node name="LeftFootTexture" type="AudioStreamPlayer3D" parent="SoundEmitters/LeftFoot" unique_id=368492] +[node name="LeftFootTexture" type="AudioStreamPlayer3D" parent="SoundEmitters/LeftFoot" unique_id=1541799094] unique_name_in_owner = true -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.032262772, 0.019309282, 0) -area_mask = 17 script = ExtResource("62_jbx34") +reverb_enabled = false reverb_volume_db = -12.0 reverb_fadeintime = -1.0 reverb_fadeouttime = -1.0 -bass_proximity = 0 -max_raycast_distance = 200 -roomsize_multiplicator = 20.0 metadata/_custom_type_script = "uid://y8x4svl5kej2" -[node name="RightFoot" type="AudioStreamPlayer3D" parent="SoundEmitters" unique_id=622217520] +[node name="RightFoot" type="AudioStreamPlayer3D" parent="SoundEmitters" unique_id=1964632523] unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.3428033, -0.8860581, 0) -area_mask = 17 script = ExtResource("62_jbx34") +reverb_enabled = false reverb_volume_db = -12.0 reverb_fadeintime = -1.0 reverb_fadeouttime = -1.0 -bass_proximity = 0 -max_raycast_distance = 200 -roomsize_multiplicator = 20.0 metadata/_custom_type_script = "uid://y8x4svl5kej2" -[node name="RightFootTexture" type="AudioStreamPlayer3D" parent="SoundEmitters/RightFoot" unique_id=721446442] +[node name="RightFootTexture" type="AudioStreamPlayer3D" parent="SoundEmitters/RightFoot" unique_id=370583799] unique_name_in_owner = true -area_mask = 17 script = ExtResource("62_jbx34") +reverb_enabled = false reverb_volume_db = -12.0 reverb_fadeintime = -1.0 reverb_fadeouttime = -1.0 -bass_proximity = 0 -max_raycast_distance = 200 -roomsize_multiplicator = 20.0 metadata/_custom_type_script = "uid://y8x4svl5kej2" -[node name="FlashlightSound" type="AudioStreamPlayer3D" parent="SoundEmitters" unique_id=1011459854] +[node name="Head" type="AudioStreamPlayer3D" parent="SoundEmitters" unique_id=799817251] unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.53598464, 0) -max_polyphony = 3 -area_mask = 17 script = ExtResource("62_jbx34") +reverb_enabled = false reverb_volume_db = -12.0 reverb_fadeintime = -1.0 reverb_fadeouttime = -1.0 -bass_proximity = 0 -max_raycast_distance = 200 -roomsize_multiplicator = 20.0 +metadata/_custom_type_script = "uid://y8x4svl5kej2" + +[node name="HeadTexture" type="AudioStreamPlayer3D" parent="SoundEmitters/Head" unique_id=732916843] +unique_name_in_owner = true +script = ExtResource("62_jbx34") +reverb_enabled = false metadata/_custom_type_script = "uid://y8x4svl5kej2" [connection signal="body_entered" from="CameraPivot/PlayerCamera/GrabbableFinder" to="Components/UiHandler" method="_on_grabbable_finder_body_entered"] diff --git a/scenes/player/player_manager.gd b/scenes/player/player_manager.gd index c1367ee..937a953 100644 --- a/scenes/player/player_manager.gd +++ b/scenes/player/player_manager.gd @@ -48,39 +48,6 @@ class_name PlayerCharacter @export_category("Player Physics") @export_flags_3d_physics var PLAYER_COLLISION_MASK: int = 16 -@onready var camera = $CameraPivot/PlayerCamera -@onready var camera_pivot = $CameraPivot -@onready var ui = $PlayerUi -@onready var ui_base_position = ui.position -@onready var in_game_menu = $InGameMenu -@onready var left_foot_sound_player = $SoundEmitters/LeftFoot -@onready var left_foot_texture_sound_player = $SoundEmitters/LeftFoot/LeftFootTexture -@onready var right_foot_sound_player = $SoundEmitters/RightFoot -@onready var right_foot_texture_sound_player = $SoundEmitters/RightFoot/RightFootTexture -@onready var flashlight_sound_player = $SoundEmitters/FlashlightSound -@onready var cursor_raycast = $CameraPivot/PlayerCamera/CursorRaycast -@onready var hold_position = $CameraPivot/PlayerCamera/HoldPosition -@onready var popup_panels = $PopupPanels - -var walking: bool = false -var running: bool = false -var crouching: bool = false -var in_menu: bool = false -var stamina: float = 100.0 -var stamina_recharge_on: bool = false -var selected_item: int = 0 -var t_bob: float = 0 -var last_bob_y: float = 0.0 -var held_object: RigidBody3D = null - -var _mouse_motion: Vector2 = Vector2.ZERO -var _mouse_motion_delta: Vector2 = Vector2.ZERO -var _last_camera_global_position: Vector3 = Vector3.ZERO -var _current_leg_is_right: bool = false ##if true: current leg is the right leg -var _current_footstep_sound: AudioStreamWAV = null -var _current_flashlight_sound: AudioStreamWAV = null -var _camera_original_position: Vector3 = Vector3(0,.75,0) - # components @onready var procedural_camera_mover: Node = %ProceduralCameraMover @onready var sound_controller: Node = %SoundController @@ -89,7 +56,7 @@ var _camera_original_position: Vector3 = Vector3(0,.75,0) @onready var player_state: Node = %PlayerState @onready var player_properties: Node = %PlayerProperties -func _process(delta: float) -> void: +func _process(_delta: float) -> void: if Input.is_action_just_pressed("next_item"): ui_handler.next_item() diff --git a/scenes/player/procedural_camera_mover_component.gd b/scenes/player/procedural_camera_mover_component.gd index 9816cd3..4a67e11 100644 --- a/scenes/player/procedural_camera_mover_component.gd +++ b/scenes/player/procedural_camera_mover_component.gd @@ -38,10 +38,11 @@ func do(delta): ui.set_stamina_bar(player_properties.stamina) var horizontal_speed = Vector3(player.velocity.x, player.velocity.y, player.velocity.z).length() + var current_sin_pos = sin(t_bob * CAMERA_BOB_FREQUENCY) + if player.is_on_floor() and horizontal_speed > 0.05: t_bob += delta * (player.velocity.length() * float(player.is_on_floor()) + (int(Input.is_action_pressed("crouch"))) * 3) - var current_sin_pos = sin(t_bob * CAMERA_BOB_FREQUENCY) #footstep handling if last_bob_y >= -.95 and current_sin_pos < -.95: @@ -53,8 +54,20 @@ func do(delta): #idle breathing elif player.is_on_floor() and horizontal_speed < 0.05: - t_bob += delta * 1 + t_bob += delta * (100 / (40 + player_properties.stamina)) + camera_breathing(t_bob) + + + if last_bob_y <= -.60 and current_sin_pos > -.60: + sound_controller.play_breath_sound(true) + + if last_bob_y >= .60 and current_sin_pos < .60: + sound_controller.play_breath_sound(false) + + last_bob_y = current_sin_pos + + else: camera.rotation.z = lerpf(camera.rotation.z,0, delta * 0.004) camera.transform.origin.y = lerpf(camera.transform.origin.y, _camera_original_position.y, delta * 5.0) diff --git a/scenes/player/sound_controller_component.gd b/scenes/player/sound_controller_component.gd index 8954129..e883084 100644 --- a/scenes/player/sound_controller_component.gd +++ b/scenes/player/sound_controller_component.gd @@ -5,20 +5,139 @@ extends Node @export var NORMAL_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##normal footsteps -- walking @export var HEAVY_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##heavy footsteps -- running @export var LIGHT_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##light footsteps -- crouching -@export var SHUFFLE_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##shuffling -- random chance of playing while running @export var FLASHLIGHT_CLICK_SOUNDS: Array[AudioStreamWAV] ##flashlight click +@export var SHUFFLE_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##shuffling -- random chance of playing while running @export var SHUFFLE_CHANCE: float = 20 ##percentage of chance for a shuffle noise to be played whilst running +@export var JUMP_LANDING_SOUNDS: Array[AudioStream] +@export var JUMP_STARTING_SOUNDS: Array[AudioStream] +@export var JUMP_LANDING_BREATH_SOUNDS: Array[AudioStream] +@export var JUMP_STARTING_BREATH_SOUNDS: Array[AudioStream] + +@export_group("Breathing") +@export var BREATHE_IN_CALM: Array[AudioStream] +@export var BREATHE_IN_LOW: Array[AudioStream] +@export var BREATHE_IN_MID: Array[AudioStream] +@export var BREATHE_IN_HEAVY: Array[AudioStream] +@export var BREATHE_IN_MAX: Array[AudioStream] +@export var BREATHE_IN_EXHAUSTED: Array[AudioStream] + +@export var BREATHE_OUT_CALM: Array[AudioStream] +@export var BREATHE_OUT_LOW: Array[AudioStream] +@export var BREATHE_OUT_MID: Array[AudioStream] +@export var BREATHE_OUT_HEAVY: Array[AudioStream] +@export var BREATHE_OUT_MAX: Array[AudioStream] +@export var BREATHE_OUT_EXHAUSTED: Array[AudioStream] + + var _current_flashlight_sound = null var _current_footstep_sound = null +var _current_jump_start_sound = null +var _current_jump_start_breath_sound = null +var _current_jump_land_sound = null +var _current_jump_land_breath_sound = null +var _current_breath_in_sound = null +var _current_breath_out_sound = null var _current_leg_is_right = false -@onready var flashlight_sound_player: SpatialAudio3D = %FlashlightSound @onready var player_state: Node = %PlayerState -@onready var left_foot_texture: SpatialAudio3D = %LeftFootTexture +@onready var left_foot: SpatialAudio3D = %LeftFoot @onready var right_foot: SpatialAudio3D = %RightFoot @onready var right_foot_texture: SpatialAudio3D = %RightFootTexture -@onready var left_foot: SpatialAudio3D = %LeftFoot +@onready var left_foot_texture: SpatialAudio3D = %LeftFootTexture +@onready var head: SpatialAudio3D = %Head +@onready var head_texture: SpatialAudio3D = %HeadTexture +@onready var player: PlayerCharacter = $"../.." + + +## TODO figure out why the sound keeps cutting off when +## shit changes, like the player_property.breathing_mode, even though its change should not change the sound of the stream but still does for some reason?? + +var debug: bool = true + +func _ready() -> void: + left_foot.debug = debug + right_foot.debug = debug + right_foot_texture.debug = debug + left_foot_texture.debug = debug + head.debug = debug + head_texture.debug = debug + +var is_right_leg := func () -> SpatialAudio3D: + if _current_leg_is_right: + return right_foot + else: + return left_foot + +##only use for sparse effects +func create_spatial_audio_sphere(pos:Vector3, audio:AudioStream, pitch:float = 1.0): + var spatial_audio = SpatialAudio3D.new() + spatial_audio.collision_mask = 1 + + spatial_audio.stream = audio + + add_child(spatial_audio) + + spatial_audio.global_position = pos + + if is_instance_valid(spatial_audio) and audio != null: + spatial_audio.do_play() + spatial_audio.get_child(0).name = audio.resource_name + + await get_tree().create_timer(audio.get_length() + 2).timeout + + if is_instance_valid(spatial_audio): + spatial_audio.queue_free() + elif is_instance_valid(spatial_audio): + spatial_audio.queue_free() + +func play_stream_on_player(player:SpatialAudio3D, audio:AudioStream, pitch: float = randf_range(.8, 1.2)): + player.process_mode = Node.PROCESS_MODE_INHERIT + player.do_set_stream(audio) + player.pitch_scale = pitch + player.do_play() + await get_tree().create_timer(3).timeout + player.process_mode = Node.PROCESS_MODE_DISABLED + +func play_breath_sound(breathe_in:bool = true): + var play_sound + + if breathe_in: + play_sound = _current_breath_in_sound + while play_sound == _current_breath_in_sound: + match player_state.breathing_mode: + player_state.breath.calm: + play_sound = BREATHE_IN_CALM.pick_random() + player_state.breath.low: + play_sound = BREATHE_IN_LOW.pick_random() + player_state.breath.mid: + play_sound = BREATHE_IN_MID.pick_random() + player_state.breath.heavy: + play_sound = BREATHE_IN_HEAVY.pick_random() + player_state.breath.max: + play_sound = BREATHE_IN_MAX.pick_random() + player_state.breath.exhausted: + play_sound = BREATHE_IN_EXHAUSTED.pick_random() + _current_breath_in_sound = play_sound + else: + play_sound = _current_breath_out_sound + while play_sound == _current_breath_out_sound: + match player_state.breathing_mode: + player_state.breath.calm: + play_sound = BREATHE_OUT_CALM.pick_random() + player_state.breath.low: + play_sound = BREATHE_OUT_LOW.pick_random() + player_state.breath.mid: + play_sound = BREATHE_OUT_MID.pick_random() + player_state.breath.heavy: + play_sound = BREATHE_OUT_HEAVY.pick_random() + player_state.breath.max: + play_sound = BREATHE_OUT_MAX.pick_random() + player_state.breath.exhausted: + play_sound = BREATHE_OUT_EXHAUSTED.pick_random() + _current_breath_out_sound = play_sound + + play_stream_on_player(head, play_sound) func play_flashlight_sound(): var play_sound = FLASHLIGHT_CLICK_SOUNDS.pick_random() @@ -26,13 +145,30 @@ func play_flashlight_sound(): while play_sound == _current_flashlight_sound: play_sound = FLASHLIGHT_CLICK_SOUNDS.pick_random() - flashlight_sound_player.do_set_stream(play_sound) - flashlight_sound_player.pitch_scale = randf_range(.8, 1.2) - flashlight_sound_player.do_play() + play_stream_on_player(head_texture, play_sound) _current_flashlight_sound = play_sound + +func play_jump_sound(start:bool = true): + var sound_to_play_foot: AudioStream = null + var sound_to_play_breath: AudioStream = null + match player.is_on_floor(): + true: + while sound_to_play_foot == _current_jump_start_sound: + sound_to_play_foot = JUMP_STARTING_SOUNDS.pick_random() + while sound_to_play_breath == _current_jump_start_breath_sound: + sound_to_play_breath = JUMP_STARTING_BREATH_SOUNDS.pick_random() + false: + while sound_to_play_foot == _current_jump_land_sound: + sound_to_play_foot = JUMP_LANDING_SOUNDS.pick_random() + while sound_to_play_breath == _current_jump_land_breath_sound: + sound_to_play_breath = JUMP_LANDING_BREATH_SOUNDS.pick_random() + + play_stream_on_player(head, sound_to_play_breath) + play_stream_on_player(is_right_leg.call(), sound_to_play_foot) + func play_footstep_sound(): - var sound_to_play + var sound_to_play:AudioStream if player_state.walking: sound_to_play = NORMAL_FOOTSTEP_SOUNDS.pick_random() while sound_to_play == _current_footstep_sound: @@ -42,14 +178,7 @@ func play_footstep_sound(): while sound_to_play == _current_footstep_sound: sound_to_play = HEAVY_FOOTSTEP_SOUNDS.pick_random() if randf_range(1, 100) > 100 - SHUFFLE_CHANCE: - match _current_leg_is_right: - true: - right_foot_texture.do_set_stream(SHUFFLE_FOOTSTEP_SOUNDS.pick_random()) - right_foot_texture.do_play() - false: - left_foot_texture.do_set_stream(SHUFFLE_FOOTSTEP_SOUNDS.pick_random()) - left_foot_texture.do_play() - + play_stream_on_player(is_right_leg.call().get_child(0), SHUFFLE_FOOTSTEP_SOUNDS.pick_random()) elif player_state.crouching: sound_to_play = LIGHT_FOOTSTEP_SOUNDS.pick_random() while sound_to_play == _current_footstep_sound: @@ -57,13 +186,5 @@ func play_footstep_sound(): _current_footstep_sound = sound_to_play - if _current_leg_is_right: - right_foot.do_set_stream(sound_to_play) - right_foot.pitch_scale = randf_range(0.8, 1.2) - right_foot.do_play() - _current_leg_is_right = false - else: - left_foot.do_set_stream(sound_to_play) - left_foot.pitch_scale = randf_range(0.8, 1.2) - left_foot.do_play() - _current_leg_is_right = true + play_stream_on_player(is_right_leg.call(), sound_to_play) + _current_leg_is_right = !_current_leg_is_right diff --git a/scenes/player/state_handler_component.gd b/scenes/player/state_handler_component.gd index 7acd909..a32d94a 100644 --- a/scenes/player/state_handler_component.gd +++ b/scenes/player/state_handler_component.gd @@ -4,6 +4,41 @@ var walking: bool = false var running: bool = false var crouching: bool = false var in_menu: bool = false +var breathing_mode = breath.calm + +enum breath { + calm, + low, + mid, + heavy, + max, + exhausted +} + +## 0 --> exhausted [br] +## 0 - 10 --> max [br] +## 10 -- 20 --> heavy [br] +## 20 -- 50 --> mid [br] +## 50 -- 80 --> low [br] +## 80 -- 100 --> calm +var _breath_change_points: Array[float] = [10, 20, 50, 80] + +@onready var player_properties: Node = %PlayerProperties + +func _process(_delta: float) -> void: + var stamina = player_properties.stamina + if stamina == 0: + breathing_mode = breath.exhausted + elif stamina <= _breath_change_points[0]: + breathing_mode = breath.max + elif stamina <= _breath_change_points[1]: + breathing_mode = breath.heavy + elif stamina <= _breath_change_points[2]: + breathing_mode = breath.mid + elif stamina <= _breath_change_points[3]: + breathing_mode = breath.low + else: + breathing_mode = breath.calm func is_crouched(yes:bool): if yes: