Forráskód Böngészése

:wrench: Randomize crash sound resource

For each impact.
DricomDragon 1 éve
szülő
commit
0995a44c98

godot/effect/crash/crash.wav → godot/effect/crash/crash0.wav


+ 3 - 3
godot/effect/crash/crash.wav.import

@@ -3,12 +3,12 @@
 importer="wav"
 type="AudioStreamWAV"
 uid="uid://dgan1kd4awbv3"
-path="res://.godot/imported/crash.wav-6daf76efbf2c8fb4389d0abeac620c85.sample"
+path="res://.godot/imported/crash0.wav-e8ef8c74c59dc0ee97f20ae8ce057e50.sample"
 
 [deps]
 
-source_file="res://effect/crash/crash.wav"
-dest_files=["res://.godot/imported/crash.wav-6daf76efbf2c8fb4389d0abeac620c85.sample"]
+source_file="res://effect/crash/crash0.wav"
+dest_files=["res://.godot/imported/crash0.wav-e8ef8c74c59dc0ee97f20ae8ce057e50.sample"]
 
 [params]
 

+ 12 - 2
godot/effect/crash/noise.gd

@@ -1,8 +1,18 @@
 extends AudioStreamPlayer3D
 
-const crash_sound: Resource = preload("res://effect/crash/crash.wav")
+const crash_sounds: Array[AudioStream] = [
+	preload("res://effect/crash/crash0.wav"),
+	preload("res://effect/crash/crash1.wav"),
+	preload("res://effect/crash/crash2.wav"),
+	preload("res://effect/crash/crash3.wav"),
+]
 
 
 func _ready() -> void:
-	stream = crash_sound
+	stream = _pick_random_sound()
 	play()
+
+
+func _pick_random_sound() -> AudioStream:
+	var rand_index: int = randi_range(0, crash_sounds.size() - 1)
+	return crash_sounds[rand_index]