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)
|
2022-01-24 16:40:11 +00:00
|
|
|
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)
|
2022-01-24 16:40:11 +00:00
|
|
|
if skidinfo < 0.25:
|
2021-11-13 21:22:07 +00:00
|
|
|
emitting = true
|
2022-01-24 16:40:11 +00:00
|
|
|
sound_player.stream_paused = false
|
2021-11-13 21:22:07 +00:00
|
|
|
else:
|
|
|
|
emitting = false
|
2022-01-24 16:40:11 +00:00
|
|
|
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:
|
2022-01-24 16:40:11 +00:00
|
|
|
sound_player.pitch_scale = 1 + pow(skidinfo, 2) - skidinfo / 3
|