bugged-racing/vehicles/tire_smoke.gd

26 lines
619 B
GDScript
Raw Normal View History

2021-11-13 21:22:07 +00:00
class_name TireSmoke
extends Particles
2021-11-13 21:48:15 +00:00
onready var sound_player: AudioStreamPlayer3D = $tire_sound_player
onready var sound_playback: AudioStreamPlayback = $tire_sound_player.get_stream_playback()
2021-11-18 23:36:05 +00:00
2021-11-13 21:48:15 +00:00
func _ready() -> void:
_update_sound(1)
sound_player.playing = true
sound_player.stream_paused = true
2021-11-13 21:48:15 +00:00
2021-11-18 23:36:05 +00:00
2021-11-13 21:22:07 +00:00
func update(skidinfo: float) -> void:
2021-11-13 21:48:15 +00:00
_update_sound(skidinfo)
if skidinfo < 0.25:
2021-11-13 21:22:07 +00:00
emitting = true
sound_player.stream_paused = false
2021-11-13 21:22:07 +00:00
else:
emitting = false
sound_player.stream_paused = true
2021-11-13 21:48:15 +00:00
2021-11-18 23:36:05 +00:00
2021-11-13 21:48:15 +00:00
func _update_sound(skidinfo: float) -> void:
sound_player.pitch_scale = 1 + pow(skidinfo, 2) - skidinfo / 3