Add improved engine, tires and wind sounds

pull/2/head
Ensar Sarajčić 2022-01-24 17:40:11 +01:00
parent 0a71908bc9
commit 873325fbe4
14 changed files with 198 additions and 83 deletions

View File

@ -12,3 +12,21 @@ Game is available on [Itch.io](https://esensar.itch.io/bugged-racing).
Game source code is licensed under [MIT license](/LICENSE).
Assets are licensed under [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/).
## Credits
This game includes assets from [opengameart.org](opengameart.org), [freesound.org](freesound.org) and other sources.
### Sounds
#### Wind sounds
[Wind sounds](/assets/wind woosh loop.ogg) used in the game is available on [opengameart.org](https://opengameart.org/content/wind-whoosh-loop) under CC0 license (public domain).
#### Engine sounds
[Engine sounds](/assets/engine.wav) used in the game is available on [freesound.org](https://freesound.org/people/MarlonHJ/sounds/242740/) under CC0 license (public domain).
#### Tire sounds
[Tire sounds](/assets/tires_squal_loop.wav) used in the game is available on [opengameart.org](https://opengameart.org/content/car-tire-squeal-skid-loop) under [CC-BY 3.0 license](https://creativecommons.org/licenses/by/3.0/). Sound is provided by [audible-edge (Tom Haigh)](http://www.freesound.org/people/audible-edge/) and submitted by [qubodup](https://opengameart.org/users/qubodup)

BIN
assets/engine.wav 100644

Binary file not shown.

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/engine.wav-cc4df8df683a7f5419ef7019228b045a.sample"
[deps]
source_file="res://assets/engine.wav"
dest_files=[ "res://.import/engine.wav-cc4df8df683a7f5419ef7019228b045a.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=true
compress/mode=0

Binary file not shown.

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/tires_squal_loop.wav-6f4aaa09ee4bdf0eca94aed4cc79779d.sample"
[deps]
source_file="res://assets/tires_squal_loop.wav"
dest_files=[ "res://.import/tires_squal_loop.wav-6f4aaa09ee4bdf0eca94aed4cc79779d.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=true
compress/mode=0

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/wind woosh loop.ogg-843e7b8cdfc6f4a378e2da0a4cb7290b.oggstr"
[deps]
source_file="res://assets/wind woosh loop.ogg"
dest_files=[ "res://.import/wind woosh loop.ogg-843e7b8cdfc6f4a378e2da0a4cb7290b.oggstr" ]
[params]
loop=true
loop_offset=0

View File

@ -46,7 +46,7 @@ scroll_horizontal_enabled = false
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/ScrollContainer"]
margin_right = 800.0
margin_bottom = 1974.0
margin_bottom = 2300.0
size_flags_horizontal = 3
[node name="Title" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"]
@ -139,20 +139,78 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="Label7" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"]
[node name="Label17" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 490.0
margin_right = 800.0
margin_bottom = 508.0
custom_fonts/font = SubResource( 2 )
text = "Credits:"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label20" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 516.0
margin_right = 800.0
margin_bottom = 534.0
custom_fonts/font = SubResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label23" type="RichTextLabel" parent="MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 542.0
margin_right = 800.0
margin_bottom = 782.0
size_flags_vertical = 0
custom_fonts/normal_font = SubResource( 2 )
bbcode_enabled = true
bbcode_text = "This game includes assets from [url=https://opengameart.org]opengameart.org[/url], [url=https://freesound.org]freesound.org[/url] and other sources.
- Sounds:
Wind sound used in the game is available on [url=https://opengameart.org/content/wind-whoosh-loop]opengameart.org[/url] under CC0 license (public domain).
Engine sound used in the game is available on [url=https://freesound.org/people/MarlonHJ/sounds/242740/]freesound.org[/url] under CC0 license (public domain).
Tire sound used in the game is available on [url=https://opengameart.org/content/car-tire-squeal-skid-loop]opengameart.org[/url] under [url=https://creativecommons.org/licenses/by/3.0/]CC-BY 3.0 license[/url]. Sound is provided by [url=http://www.freesound.org/people/audible-edge/]audible-edge (Tom Haigh)[/url] and submitted by [url=https://opengameart.org/users/qubodup]qubodup[/url]"
text = "This game includes assets from opengameart.org, freesound.org and other sources.
- Sounds:
Wind sound used in the game is available on opengameart.org under CC0 license (public domain).
Engine sound used in the game is available on freesound.org under CC0 license (public domain).
Tire sound used in the game is available on opengameart.org under CC-BY 3.0 license. Sound is provided by audible-edge (Tom Haigh) and submitted by qubodup"
fit_content_height = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label21" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 790.0
margin_right = 800.0
margin_bottom = 808.0
custom_fonts/font = SubResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label7" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 816.0
margin_right = 800.0
margin_bottom = 834.0
custom_fonts/font = SubResource( 2 )
text = "Open source licences:"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label8" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 516.0
margin_top = 842.0
margin_right = 800.0
margin_bottom = 534.0
margin_bottom = 860.0
custom_fonts/font = SubResource( 2 )
align = 1
__meta__ = {
@ -160,9 +218,9 @@ __meta__ = {
}
[node name="Label11" type="RichTextLabel" parent="MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 542.0
margin_top = 868.0
margin_right = 800.0
margin_bottom = 562.0
margin_bottom = 888.0
custom_fonts/normal_font = SubResource( 2 )
bbcode_enabled = true
bbcode_text = "Godot Engine (also available in [url=https://godotengine.org/license]web version[/url]):"
@ -170,9 +228,9 @@ text = "Godot Engine (also available in web version):"
fit_content_height = true
[node name="Label9" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 570.0
margin_top = 896.0
margin_right = 800.0
margin_bottom = 1092.0
margin_bottom = 1418.0
custom_fonts/font = SubResource( 2 )
text = "
This game uses Godot Engine, available under the following license:
@ -190,9 +248,9 @@ __meta__ = {
}
[node name="Label12" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 1100.0
margin_top = 1426.0
margin_right = 800.0
margin_bottom = 1118.0
margin_bottom = 1444.0
custom_fonts/font = SubResource( 2 )
align = 1
__meta__ = {
@ -200,9 +258,9 @@ __meta__ = {
}
[node name="Label10" type="RichTextLabel" parent="MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 1126.0
margin_top = 1452.0
margin_right = 800.0
margin_bottom = 1206.0
margin_bottom = 1532.0
custom_fonts/normal_font = SubResource( 2 )
bbcode_enabled = true
bbcode_text = "[url=https://www.freetype.org/]FreeType[/url]:
@ -214,9 +272,9 @@ text = "FreeType:
fit_content_height = true
[node name="Label13" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 1214.0
margin_top = 1540.0
margin_right = 800.0
margin_bottom = 1232.0
margin_bottom = 1558.0
custom_fonts/font = SubResource( 2 )
align = 1
__meta__ = {
@ -224,9 +282,9 @@ __meta__ = {
}
[node name="Label14" type="RichTextLabel" parent="MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 1240.0
margin_top = 1566.0
margin_right = 800.0
margin_bottom = 1660.0
margin_bottom = 1986.0
custom_fonts/normal_font = SubResource( 2 )
bbcode_enabled = true
bbcode_text = "[url=http://enet.bespin.org/]ENet[/url]:
@ -252,9 +310,9 @@ text = "ENet:
fit_content_height = true
[node name="Label15" type="Label" parent="MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 1668.0
margin_top = 1994.0
margin_right = 800.0
margin_bottom = 1686.0
margin_bottom = 2012.0
custom_fonts/font = SubResource( 2 )
align = 1
__meta__ = {
@ -262,9 +320,9 @@ __meta__ = {
}
[node name="Label16" type="RichTextLabel" parent="MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 1694.0
margin_top = 2020.0
margin_right = 800.0
margin_bottom = 1974.0
margin_bottom = 2300.0
custom_fonts/normal_font = SubResource( 2 )
bbcode_enabled = true
bbcode_text = "[url=https://tls.mbed.org/]MBedTLS[/url]:
@ -293,6 +351,7 @@ fit_content_height = true
[connection signal="meta_clicked" from="MarginContainer/ScrollContainer/VBoxContainer/Label3" to="." method="_on_link_meta_clicked"]
[connection signal="meta_clicked" from="MarginContainer/ScrollContainer/VBoxContainer/Label19" to="." method="_on_link_meta_clicked"]
[connection signal="meta_clicked" from="MarginContainer/ScrollContainer/VBoxContainer/Label18" to="." method="_on_link_meta_clicked"]
[connection signal="meta_clicked" from="MarginContainer/ScrollContainer/VBoxContainer/Label23" to="." method="_on_link_meta_clicked"]
[connection signal="meta_clicked" from="MarginContainer/ScrollContainer/VBoxContainer/Label11" to="." method="_on_link_meta_clicked"]
[connection signal="meta_clicked" from="MarginContainer/ScrollContainer/VBoxContainer/Label10" to="." method="_on_link_meta_clicked"]
[connection signal="meta_clicked" from="MarginContainer/ScrollContainer/VBoxContainer/Label14" to="." method="_on_link_meta_clicked"]

View File

@ -6,21 +6,16 @@
[ext_resource path="res://vehicles/pedal.gd" type="Script" id=4]
[ext_resource path="res://vehicles/meter.gd" type="Script" id=5]
[ext_resource path="res://vehicles/steering_controller.gd" type="Script" id=6]
[ext_resource path="res://assets/engine.wav" type="AudioStream" id=7]
[ext_resource path="res://assets/wind woosh loop.ogg" type="AudioStream" id=8]
[sub_resource type="Curve" id=3]
_data = [ Vector2( 0, 0 ), 0.0, 3.60634, 0, 1, Vector2( 0.15566, 0.561364 ), 1.56017, 1.56017, 0, 0, Vector2( 0.830189, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ]
[sub_resource type="Curve" id=4]
_data = [ Vector2( 0, 0.492045 ), 0.0, 0.0, 0, 0, Vector2( 0.15566, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.212264, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.29717, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.410377, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.481132, 0.701136 ), 0.0, 0.0, 0, 0, Vector2( 0.566038, 0.282955 ), 0.0, 0.0, 0, 0, Vector2( 0.589623, 0.6375 ), 0.0, 0.0, 0, 0, Vector2( 0.660377, 0.373864 ), 0.0, 0.0, 0, 0, Vector2( 0.669811, 0.5375 ), 0.0, 0.0, 0, 0, Vector2( 0.764151, 0.0284091 ), 0.0, 0.0, 0, 0, Vector2( 0.811321, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.938679, 0 ), 0.0, 0.0, 0, 0, Vector2( 1, 1 ), 0.0, 0.0, 0, 0 ]
[sub_resource type="CapsuleShape" id=11]
radius = 0.394377
height = 2.03536
[sub_resource type="AudioStreamGenerator" id=2]
mix_rate = 5500.0
buffer_length = 1.0
[sub_resource type="Curve" id=9]
_data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.493182 ), 0.0, 0.0, 0, 0 ]
@ -60,7 +55,6 @@ final_drive = 4.0
max_rpm = 8000.0
gear_switch_time = 0.5
power_curve = SubResource( 3 )
sound_curve = SubResource( 4 )
[node name="rear_right" parent="." index="0"]
use_as_traction = true
@ -145,8 +139,8 @@ shape = SubResource( 11 )
[node name="engine_sound_player" type="AudioStreamPlayer3D" parent="." index="7"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.14201, 0.968668 )
stream = SubResource( 2 )
unit_db = 14.0
stream = ExtResource( 7 )
pitch_scale = 0.1
bus = "Sound"
[node name="Smoke" type="Particles" parent="." index="8"]
@ -180,6 +174,10 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.535274, 1.89154 )
[node name="static_follow" type="Position3D" parent="." index="16"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.59115, -3.01375 )
[node name="wind_sound_player" type="AudioStreamPlayer3D" parent="." index="17"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.08447, 1.12391 )
stream = ExtResource( 8 )
[connection signal="brake_updated" from="." to="chassis/cockpit/brake_pedal" method="_on_value_updated"]
[connection signal="clutch_updated" from="." to="chassis/cockpit/clutch_pedal" method="_on_value_updated"]
[connection signal="rpm_updated" from="." to="chassis/cockpit/rpm_meter" method="_on_value_updated"]

View File

@ -5,21 +5,17 @@
[ext_resource path="res://vehicles/vehicle.gd" type="Script" id=3]
[ext_resource path="res://vehicles/steering_controller.gd" type="Script" id=4]
[ext_resource path="res://vehicles/meter.gd" type="Script" id=5]
[ext_resource path="res://assets/engine.wav" type="AudioStream" id=6]
[ext_resource path="res://vehicles/pedal.gd" type="Script" id=7]
[ext_resource path="res://assets/wind woosh loop.ogg" type="AudioStream" id=8]
[sub_resource type="Curve" id=2]
_data = [ Vector2( 0, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.0660377, 0.243255 ), 0.0, 0.0, 0, 0, Vector2( 0.25, 0.563636 ), 4.02975, 4.02975, 0, 0, Vector2( 0.518868, 0.761364 ), 3.22818, 3.22818, 0, 0, Vector2( 0.849057, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ]
[sub_resource type="Curve" id=4]
_data = [ Vector2( 0, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.0849057, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.15566, 0.746591 ), 0.0, 0.0, 0, 0, Vector2( 0.349057, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.382075, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.400943, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.438679, 0 ), 0.0, 0.0, 0, 0, Vector2( 1, 1 ), 0.0, 0.0, 0, 0 ]
[sub_resource type="CapsuleShape" id=11]
radius = 0.452181
height = 2.78888
[sub_resource type="AudioStreamGenerator" id=3]
mix_rate = 5500.0
[sub_resource type="Curve" id=8]
_data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.205682 ), 0.0, 0.0, 0, 0 ]
@ -55,8 +51,8 @@ base_engine_pitch = 0.45
drag_factor = 1.65
downforce_factor = 1.1
gear_ratios = [ 3.8, 2.7, 2.2, 1.75, 1.4, 1.2 ]
max_rpm = 5000.0
power_curve = SubResource( 2 )
sound_curve = SubResource( 4 )
automatic_gear_up_threshold = 0.85
automatic_gear_down_threshold = 0.4
@ -144,9 +140,9 @@ damping_relaxation = 0.94
transform = Transform( -1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
[node name="engine_sound_player" type="AudioStreamPlayer3D" parent="." index="7"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.14201, 0.968668 )
stream = SubResource( 3 )
unit_db = 14.0
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.14201, -1.46122 )
stream = ExtResource( 6 )
pitch_scale = 0.1
bus = "Sound"
[node name="Smoke" type="Particles" parent="." index="8"]
@ -179,6 +175,10 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.811448, 1.79879 )
[node name="static_follow" type="Position3D" parent="." index="16"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.15146, -4.84184 )
[node name="wind_sound_player" type="AudioStreamPlayer3D" parent="." index="17"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.39214, 1.12139 )
stream = ExtResource( 8 )
[connection signal="brake_updated" from="." to="chassis/cockpit/brake_pedal" method="_on_value_updated"]
[connection signal="clutch_updated" from="." to="chassis/cockpit/clutch_pedal" method="_on_value_updated"]
[connection signal="rpm_updated" from="." to="chassis/cockpit/rpm_meter" method="_on_value_updated"]

View File

@ -6,20 +6,16 @@
[ext_resource path="res://vehicles/steering_controller.gd" type="Script" id=4]
[ext_resource path="res://vehicles/pedal.gd" type="Script" id=5]
[ext_resource path="res://vehicles/meter.gd" type="Script" id=6]
[ext_resource path="res://assets/engine.wav" type="AudioStream" id=7]
[ext_resource path="res://assets/wind woosh loop.ogg" type="AudioStream" id=8]
[sub_resource type="Curve" id=18]
_data = [ Vector2( 0, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.179245, 0.584091 ), 4.91185, 4.91185, 0, 0, Vector2( 0.603774, 0.954545 ), 6.05975, 6.05975, 0, 0, Vector2( 0.806604, 0.989773 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ]
[sub_resource type="Curve" id=19]
_data = [ Vector2( 0, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.127358, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.174528, 0.65 ), 0.0, 0.0, 0, 0, Vector2( 0.212264, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.353774, 0.35 ), 0.0, 0.0, 0, 0, Vector2( 0.363208, 0.968182 ), 0.0, 0.0, 0, 0, Vector2( 0.485849, 0.313636 ), 0.0, 0.0, 0, 0, Vector2( 0.627358, 0.140909 ), 0.0, 0.0, 0, 0, Vector2( 0.721698, 0.259091 ), 0.0, 0.0, 0, 0, Vector2( 0.745283, 0.623864 ), 0.0, 0.0, 0, 0, Vector2( 0.872642, 0.794318 ), 0.0, 0.0, 0, 0, Vector2( 0.915094, 0.248864 ), 0.0, 0.0, 0, 0, Vector2( 0.933962, 0.5125 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ]
[sub_resource type="CapsuleShape" id=20]
radius = 0.274866
height = 2.75974
[sub_resource type="AudioStreamGenerator" id=12]
mix_rate = 5500.0
[sub_resource type="Gradient" id=13]
offsets = PoolRealArray( 0, 0.5, 1 )
colors = PoolColorArray( 0, 0.278431, 0.270588, 1, 0.356863, 0.764706, 0.670588, 1, 1, 1, 1, 1 )
@ -66,7 +62,6 @@ gear_ratios = [ 3.5, 2.95, 2.64, 2.0, 1.67, 1.42 ]
final_drive = 4.36
max_rpm = 9000.0
power_curve = SubResource( 18 )
sound_curve = SubResource( 19 )
[node name="rear_left" parent="." index="0"]
use_as_traction = true
@ -138,8 +133,8 @@ shape = SubResource( 20 )
[node name="engine_sound_player" type="AudioStreamPlayer3D" parent="." index="7"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.791119, -2.27857 )
stream = SubResource( 12 )
unit_db = 14.0
stream = ExtResource( 7 )
pitch_scale = 0.1
bus = "Sound"
[node name="Smoke" type="Particles" parent="." index="8"]
@ -172,6 +167,10 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.605405, 1.5324 )
[node name="static_follow" type="Position3D" parent="." index="16"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.88984, -4.78212 )
[node name="wind_sound_player" type="AudioStreamPlayer3D" parent="." index="17"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.18462, 0.791153 )
stream = ExtResource( 8 )
[connection signal="brake_updated" from="." to="chassis/cockpit/brake_pedal" method="_on_value_updated"]
[connection signal="clutch_updated" from="." to="chassis/cockpit/clutch_pedal" method="_on_value_updated"]
[connection signal="rpm_updated" from="." to="chassis/cockpit/steering_controller/rpm_meter" method="_on_value_updated"]

View File

@ -7,24 +7,19 @@ onready var sound_playback: AudioStreamPlayback = $tire_sound_player.get_stream_
func _ready() -> void:
_update_sound(1)
# sound_player.play()
sound_player.playing = true
sound_player.stream_paused = true
func update(skidinfo: float) -> void:
_update_sound(skidinfo)
if skidinfo < 0.5:
if skidinfo < 0.25:
emitting = true
sound_player.stream_paused = false
else:
emitting = false
sound_player.stream_paused = true
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 += 1
to_fill -= 1
sound_player.pitch_scale = 1 + pow(skidinfo, 2) - skidinfo / 3

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://vehicles/tire_smoke.gd" type="Script" id=1]
[ext_resource path="res://assets/tires_squal_loop.wav" type="AudioStream" id=2]
[sub_resource type="Curve" id=1]
_data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.0170454 ), 0.0, 0.0, 0, 0 ]
@ -25,9 +26,6 @@ material = SubResource( 4 )
radial_segments = 4
rings = 4
[sub_resource type="AudioStreamGenerator" id=6]
mix_rate = 5000.0
[node name="tire_smoke" type="Particles"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.541801, 0 )
emitting = false
@ -39,8 +37,7 @@ draw_pass_1 = SubResource( 5 )
script = ExtResource( 1 )
[node name="tire_sound_player" type="AudioStreamPlayer3D" parent="."]
stream = SubResource( 6 )
unit_db = 25.0
unit_size = 2.0
stream = ExtResource( 2 )
max_db = 1.0
bus = "Sound"
area_mask = 2

View File

@ -57,7 +57,7 @@ onready var rrsmoke: TireSmoke = $rr_tire_smoke
onready var rlsmoke: TireSmoke = $rl_tire_smoke
onready var engine_sound_player: AudioStreamPlayer3D = $engine_sound_player
onready var engine_sound_playback: AudioStreamPlayback = $engine_sound_player.get_stream_playback()
onready var wind_sound_player: AudioStreamPlayer3D = $wind_sound_player
onready var max_steer_input_rad: float = deg2rad(max_steer_input)
@ -92,6 +92,7 @@ func _ready():
_generate_engine_sound(0)
engine_sound_player.play()
wind_sound_player.play()
func get_cockpit_position() -> Node:
@ -230,6 +231,7 @@ func _physics_process(delta: float):
var power_factor = power_curve.interpolate_baked(rpm_factor)
_generate_engine_sound(rpm_factor)
_generate_wind_sound(speed)
# Transfer to transmission
var transmission_input = power_factor * (1 - clutch_position) * _get_gear_ratio()
@ -269,22 +271,12 @@ func _physics_process(delta: float):
func _generate_engine_sound(rpm_factor):
engine_sound_player.pitch_scale = base_engine_pitch + 2 * rpm_factor
var to_fill = engine_sound_playback.get_frames_available()
var factor = rpm_factor
if to_fill <= 0:
return
var fill_segment = 1.0 / to_fill
var fill_percent = 0.0
while to_fill > 0:
engine_sound_playback.push_frame(Vector2(1.0, 1.0) * factor)
factor += (
cos(factor)
* sin(factor)
* (1 + to_fill % 2)
* ((sound_curve.interpolate_baked(fill_percent) - 0.5) * 2)
)
to_fill -= 1
fill_percent += fill_segment
engine_sound_player.unit_db = 1 + 2 * rpm_factor
func _generate_wind_sound(speed):
wind_sound_player.pitch_scale = 1 + speed / 150
wind_sound_player.unit_db = pow(speed, 2) / 1500 * (0.5 + drag_factor) - 20
func _synchronize():