meat_madness_redux/godot/assets/meat_creek/WaterSound.gd

35 lines
953 B
GDScript3
Raw Normal View History

2022-12-27 20:06:15 -07:00
extends AudioStreamPlayer
export var base_volume: float = -7.0
export var base_pitch: float = 1.0
export var submerged_volume: float = 10.0
export var submerged_pitch: float = 0.75
export var pit_volume: float = 0
export var pit_pitch: float = 0.25
func _ready():
var _ignore = GlobalEventBus.connect("player_entered_meat_sink", self, "enter_water")
_ignore = GlobalEventBus.connect("player_exited_meat_sink", self, "exit_water")
volume_db = base_volume
var water = 0
func enter_water():
water += 1
func exit_water():
water -= 1
func _process(delta):
var target_volume = base_volume
var target_pitch = base_pitch
if water:
target_volume = submerged_volume
target_pitch = submerged_pitch
if Util.player.camera_position().y <= -18:
target_volume = pit_volume
target_pitch = pit_pitch
volume_db = Util.clamped_lerp(volume_db, target_volume, delta*5, 0.01)
pitch_scale = Util.clamped_lerp(pitch_scale, target_pitch, delta*5, 0.01)