teststrecke-game/scripts/sfx.gd

32 lines
1 KiB
GDScript3
Raw Permalink Normal View History

2024-11-10 17:13:14 +00:00
extends Node
@onready var sfx_crash: AudioStreamPlayer = $SFXCrash
@onready var sfx_crash_car_to_car: AudioStreamPlayer = $SFXCrashCarToCar
2024-11-10 19:31:11 +00:00
@onready var sfx_sliding: AudioStreamPlayer = $SFXSliding
2024-11-10 17:13:14 +00:00
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func crashBarrier(velocity):
if not sfx_crash.playing:
#print("Play Crash sound v="+str(velocity))
sfx_crash.set_volume_db(linear_to_db(clamp(remap(velocity, 100,300,0.0,1.0),0,1)))
sfx_crash.play()
func crashCarToCar(velocity):
if not sfx_crash_car_to_car.playing:
#print("Play sfx_crash_car_to_car sound v="+str(velocity))
sfx_crash_car_to_car.set_volume_db(linear_to_db(clamp(remap(velocity, 200,300,0.0,1.0),0,1)))
sfx_crash_car_to_car.play()
2024-11-10 19:31:11 +00:00
func sliding(velocity):
if not sfx_sliding.playing:
sfx_sliding.set_volume_db(linear_to_db(clamp(remap(velocity, 100,300,0.0,1.0),0,1)))
sfx_sliding.play()