Add tire sounds
parent
6d663bdfa0
commit
2bdced47ea
|
@ -5,4 +5,6 @@
|
||||||
[resource]
|
[resource]
|
||||||
background_mode = 2
|
background_mode = 2
|
||||||
background_sky = SubResource( 1 )
|
background_sky = SubResource( 1 )
|
||||||
|
fog_enabled = true
|
||||||
|
fog_depth_end = 482.6
|
||||||
dof_blur_far_distance = 136.42
|
dof_blur_far_distance = 136.42
|
||||||
|
|
|
@ -148,7 +148,7 @@ func _physics_process(delta: float):
|
||||||
steering = steering_input * lerp(max_steer_angle_rad, speed_steer_angle_rad, steer_speed_factor)
|
steering = steering_input * lerp(max_steer_angle_rad, speed_steer_angle_rad, steer_speed_factor)
|
||||||
|
|
||||||
func _generate_engine_sound(rpm_factor):
|
func _generate_engine_sound(rpm_factor):
|
||||||
engine_sound_player.pitch_scale = BASE_ENGINE_PITCH + rpm_factor
|
engine_sound_player.pitch_scale = BASE_ENGINE_PITCH + 2 * rpm_factor
|
||||||
var to_fill = engine_sound_playback.get_frames_available()
|
var to_fill = engine_sound_playback.get_frames_available()
|
||||||
var factor = rpm_factor
|
var factor = rpm_factor
|
||||||
if to_fill <= 0:
|
if to_fill <= 0:
|
||||||
|
|
|
@ -1,8 +1,27 @@
|
||||||
class_name TireSmoke
|
class_name TireSmoke
|
||||||
extends Particles
|
extends Particles
|
||||||
|
|
||||||
|
onready var sound_player: AudioStreamPlayer3D = $tire_sound_player
|
||||||
|
onready var sound_playback: AudioStreamPlayback = $tire_sound_player.get_stream_playback()
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
_update_sound(1)
|
||||||
|
# sound_player.play()
|
||||||
|
|
||||||
func update(skidinfo: float) -> void:
|
func update(skidinfo: float) -> void:
|
||||||
|
_update_sound(skidinfo)
|
||||||
if skidinfo < 0.5:
|
if skidinfo < 0.5:
|
||||||
emitting = true
|
emitting = true
|
||||||
else:
|
else:
|
||||||
emitting = false
|
emitting = false
|
||||||
|
|
||||||
|
func _update_sound(skidinfo: float) -> void:
|
||||||
|
sound_player.pitch_scale = 1 + (1 - skidinfo)
|
||||||
|
var to_fill = sound_playback.get_frames_available()
|
||||||
|
var factor = (1 - skidinfo) * 2
|
||||||
|
if to_fill <= 0:
|
||||||
|
return
|
||||||
|
while to_fill > 0:
|
||||||
|
sound_playback.push_frame(Vector2(1.0, 1.0) * factor)
|
||||||
|
factor += sin(factor) * 2
|
||||||
|
to_fill -= 1
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=7 format=2]
|
[gd_scene load_steps=8 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://vehicles/tire_smoke.gd" type="Script" id=1]
|
[ext_resource path="res://vehicles/tire_smoke.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
@ -25,6 +25,9 @@ material = SubResource( 4 )
|
||||||
radial_segments = 4
|
radial_segments = 4
|
||||||
rings = 4
|
rings = 4
|
||||||
|
|
||||||
|
[sub_resource type="AudioStreamGenerator" id=6]
|
||||||
|
mix_rate = 5500.0
|
||||||
|
|
||||||
[node name="tire_smoke" type="Particles"]
|
[node name="tire_smoke" type="Particles"]
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.541801, 0 )
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.541801, 0 )
|
||||||
emitting = false
|
emitting = false
|
||||||
|
@ -34,3 +37,9 @@ local_coords = false
|
||||||
process_material = SubResource( 3 )
|
process_material = SubResource( 3 )
|
||||||
draw_pass_1 = SubResource( 5 )
|
draw_pass_1 = SubResource( 5 )
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="tire_sound_player" type="AudioStreamPlayer3D" parent="."]
|
||||||
|
stream = SubResource( 6 )
|
||||||
|
unit_db = 25.0
|
||||||
|
unit_size = 2.0
|
||||||
|
area_mask = 2
|
||||||
|
|
Loading…
Reference in New Issue