Play grunk collection noises based on modeled decay

This commit is contained in:
Rob Kelly 2025-08-18 17:29:14 -06:00
parent 0edf520a21
commit 065b9521b6
17 changed files with 215 additions and 6 deletions

Binary file not shown.

BIN
asset_dev/sfx/collect.aup3 Normal file

Binary file not shown.

BIN
assets/sfx/tools/collect1.wav (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://dxstv7gr5n2yg"
path="res://.godot/imported/collect1.wav-11646d00ef9f7f39c8a9fae841f61c4f.sample"
[deps]
source_file="res://assets/sfx/tools/collect1.wav"
dest_files=["res://.godot/imported/collect1.wav-11646d00ef9f7f39c8a9fae841f61c4f.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_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

BIN
assets/sfx/tools/collect2.wav (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://b4prjqpwjpv7p"
path="res://.godot/imported/collect2.wav-cf3cbf3e79a99d102ddf430dfdd5dce7.sample"
[deps]
source_file="res://assets/sfx/tools/collect2.wav"
dest_files=["res://.godot/imported/collect2.wav-cf3cbf3e79a99d102ddf430dfdd5dce7.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_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

BIN
assets/sfx/tools/collect3.wav (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://cpkatef4t1pwx"
path="res://.godot/imported/collect3.wav-7676f4d20a076c2b18b80ecc0b3ca293.sample"
[deps]
source_file="res://assets/sfx/tools/collect3.wav"
dest_files=["res://.godot/imported/collect3.wav-7676f4d20a076c2b18b80ecc0b3ca293.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_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

BIN
assets/sfx/tools/collect4.wav (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bpx8hu288l8pe"
path="res://.godot/imported/collect4.wav-a71eb8ba5bdd639c52d02fa1a3726783.sample"
[deps]
source_file="res://assets/sfx/tools/collect4.wav"
dest_files=["res://.godot/imported/collect4.wav-a71eb8ba5bdd639c52d02fa1a3726783.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_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

View File

@ -118,7 +118,7 @@ seamless = true
seamless_blend_skirt = 0.5
noise = ExtResource("7_7cbja")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_aix42"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_qjnj2"]
resource_local_to_scene = true
render_priority = 0
shader = ExtResource("6_6frcc")
@ -306,7 +306,7 @@ unique_name_in_owner = true
body = NodePath("..")
mesh_instance = NodePath("../..")
initial_mask = ExtResource("5_aix42")
source_gunk_material = SubResource("ShaderMaterial_aix42")
source_gunk_material = SubResource("ShaderMaterial_qjnj2")
[node name="Bulkhead" parent="." instance=ExtResource("8_ujrcv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6.5, 0, -2)

View File

@ -164,7 +164,6 @@ collision_mode = 2
[node name="GrunkSplatter" type="GPUParticles3D"]
sorting_offset = 9.0
emitting = false
amount = 64
lifetime = 0.3
one_shot = true
@ -176,7 +175,6 @@ script = ExtResource("2_grvat")
[node name="SubSplatter" type="GPUParticles3D" parent="."]
unique_name_in_owner = true
sorting_offset = 9.0
emitting = false
amount = 4
lifetime = 0.3
one_shot = true
@ -211,7 +209,6 @@ shape = SubResource("SphereShape3D_6adkd")
[node name="GrunkDust" parent="." instance=ExtResource("7_opa8j")]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0)
emitting = false
amount = 512
lifetime = 1.2
one_shot = true

View File

@ -0,0 +1,42 @@
extends AudioStreamPlayer
@export var max_meter := 1000.0
@export var epsilon := 20.0
@export var decay_rate := 0.95
@export var interval_curve: Curve
var _meter := 0.0
@onready var cooldown: Timer = %Cooldown
@onready var debug_meter: ProgressBar = %DebugMeter
func _ready() -> void:
if World.instance and World.instance.manager:
World.instance.manager.grunk_collected.connect(on_grunk_collected)
func trigger() -> void:
play()
if _meter > epsilon:
restart_interval()
func restart_interval() -> void:
var interval := interval_curve.sample(_meter)
print_debug("meter: ", _meter, "; interval: ", interval)
cooldown.start(interval)
func on_grunk_collected(delta: float) -> void:
var old_meter := _meter
_meter = clampf(_meter + delta, epsilon, max_meter)
if old_meter <= epsilon:
trigger()
func _process(delta: float) -> void:
var weight := 1 - exp(-decay_rate * delta)
_meter = lerpf(_meter, 0.0, weight)
debug_meter.value = _meter

View File

@ -0,0 +1 @@
uid://dwt66u7ua1to4

View File

@ -0,0 +1,49 @@
[gd_scene load_steps=8 format=3 uid="uid://cbtmhu787diev"]
[ext_resource type="AudioStream" uid="uid://dxstv7gr5n2yg" path="res://assets/sfx/tools/collect1.wav" id="1_h705l"]
[ext_resource type="AudioStream" uid="uid://b4prjqpwjpv7p" path="res://assets/sfx/tools/collect2.wav" id="2_uq3q4"]
[ext_resource type="AudioStream" uid="uid://cpkatef4t1pwx" path="res://assets/sfx/tools/collect3.wav" id="3_h5hmg"]
[ext_resource type="AudioStream" uid="uid://bpx8hu288l8pe" path="res://assets/sfx/tools/collect4.wav" id="4_8ycea"]
[ext_resource type="Script" uid="uid://dwt66u7ua1to4" path="res://src/player/grunk_collection_sfx/grunk_collection_sfx.gd" id="5_ihwko"]
[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_bgxyk"]
random_pitch = 1.1
streams_count = 4
stream_0/stream = ExtResource("1_h705l")
stream_1/stream = ExtResource("2_uq3q4")
stream_2/stream = ExtResource("3_h5hmg")
stream_3/stream = ExtResource("4_8ycea")
[sub_resource type="Curve" id="Curve_h705l"]
_limits = [0.0, 1.0, 0.0, 1000.0]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(580.268, 0.0565841), 0.0, 0.0, 0, 0]
point_count = 2
[node name="GrunkCollectionSFX" type="AudioStreamPlayer"]
stream = SubResource("AudioStreamRandomizer_bgxyk")
volume_db = -4.0
max_polyphony = 4
script = ExtResource("5_ihwko")
epsilon = 100.0
decay_rate = 0.99
interval_curve = SubResource("Curve_h705l")
[node name="Cooldown" type="Timer" parent="."]
unique_name_in_owner = true
wait_time = 0.12
one_shot = true
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="DebugMeter" type="ProgressBar" parent="CanvasLayer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(300, 0)
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -27.0
offset_right = 4.0
grow_vertical = 0
max_value = 1000.0
[connection signal="timeout" from="Cooldown" to="." method="trigger"]

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=69 format=3 uid="uid://bwe2jdmvinhqd"]
[gd_scene load_steps=70 format=3 uid="uid://bwe2jdmvinhqd"]
[ext_resource type="Script" uid="uid://buwh0g1ga2aka" path="res://src/player/player.gd" id="1_npueo"]
[ext_resource type="Script" uid="uid://cx1yt0drthpw3" path="res://src/player/camera_controller.gd" id="2_veeqv"]
@ -39,6 +39,7 @@
[ext_resource type="Script" uid="uid://b5loa2u6s5l5c" path="res://src/player/rigid_body_physics.gd" id="36_phdu6"]
[ext_resource type="Script" uid="uid://dg55jdoyctdq6" path="res://src/game/tutorial/tutorial_timer.gd" id="38_evlgt"]
[ext_resource type="AudioStream" uid="uid://c01y7jauf4spn" path="res://assets/sfx/tools/tool_switch_v0.wav" id="39_gsylq"]
[ext_resource type="PackedScene" uid="uid://cbtmhu787diev" path="res://src/player/grunk_collection_sfx/grunk_collection_sfx.tscn" id="40_utg71"]
[sub_resource type="Animation" id="Animation_x42xx"]
length = 0.001
@ -834,3 +835,5 @@ tutorial_key = &"game/tutorial/progress/move"
unique_name_in_owner = true
stream = ExtResource("39_gsylq")
pitch_scale = 1.8
[node name="GrunkCollectionSFX" parent="." instance=ExtResource("40_utg71")]

View File

@ -122,6 +122,12 @@
- retrieved from https://freesound.org/people/geodylabs/sounds/122810/
- assets/sfx/tools/spray.wav
- modified
- "thumping_on_a_plastic_bottle.wav"
- author: joedeshon
- CC BY 4.0
- retrieved from https://freesound.org/people/joedeshon/sounds/635106/
- assets/sfx/tools/collect*.wav
- modified
- Fonts
- Silkscreen
- author: Jason Kottke