Adding generated sounds to car
All checks were successful
Deploy Promiscuity Auth API / deploy (push) Successful in 1m14s
Deploy Promiscuity Character API / deploy (push) Successful in 1m14s
Deploy Promiscuity Crafting API / deploy (push) Successful in 1m14s
Deploy Promiscuity Inventory API / deploy (push) Successful in 1m13s
Deploy Promiscuity Locations API / deploy (push) Successful in 1m13s
Deploy Promiscuity Mail API / deploy (push) Successful in 1m13s
Deploy Promiscuity World API / deploy (push) Successful in 1m13s
k8s smoke test / test (push) Successful in 35s
All checks were successful
Deploy Promiscuity Auth API / deploy (push) Successful in 1m14s
Deploy Promiscuity Character API / deploy (push) Successful in 1m14s
Deploy Promiscuity Crafting API / deploy (push) Successful in 1m14s
Deploy Promiscuity Inventory API / deploy (push) Successful in 1m13s
Deploy Promiscuity Locations API / deploy (push) Successful in 1m13s
Deploy Promiscuity Mail API / deploy (push) Successful in 1m13s
Deploy Promiscuity World API / deploy (push) Successful in 1m13s
k8s smoke test / test (push) Successful in 35s
This commit is contained in:
parent
9e3df6c691
commit
3b21cf3182
@ -12,4 +12,4 @@ _surfaces = [{
|
|||||||
"vertex_count": 8,
|
"vertex_count": 8,
|
||||||
"vertex_data": PackedByteArray("AAAAvwAAgD8AAAAAAAAAPwAAAAAAAAAAAAAAvwAAAAAAAAAAAAAAPwAAgD8AAAAAAAAAAAAAgD8AAAC/AAAAAAAAAAAAAAA/AAAAAAAAAAAAAAC/AAAAAAAAgD8AAAA//3//f////7//f/9/////v/9//3////+//3//f////78AAP9//3//vwAA/3//f/+/AAD/f/9//78AAP9//3//vw==")
|
"vertex_data": PackedByteArray("AAAAvwAAgD8AAAAAAAAAPwAAAAAAAAAAAAAAvwAAAAAAAAAAAAAAPwAAgD8AAAAAAAAAAAAAgD8AAAC/AAAAAAAAAAAAAAA/AAAAAAAAAAAAAAC/AAAAAAAAgD8AAAA//3//f////7//f/9/////v/9//3////+//3//f////78AAP9//3//vwAA/3//f/+/AAD/f/9//78AAP9//3//vw==")
|
||||||
}]
|
}]
|
||||||
metadata/GodotVersion = "4.6.3-stable (official)"
|
metadata/GodotVersion = "4.6.2-stable (official)"
|
||||||
|
|||||||
BIN
game/assets/audio/vehicles/car/car_brake.wav
Normal file
BIN
game/assets/audio/vehicles/car/car_brake.wav
Normal file
Binary file not shown.
24
game/assets/audio/vehicles/car/car_brake.wav.import
Normal file
24
game/assets/audio/vehicles/car/car_brake.wav.import
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamWAV"
|
||||||
|
uid="uid://b2e0ls6ymw45i"
|
||||||
|
path="res://.godot/imported/car_brake.wav-359538a9b1ba4240ae07e54477629dbb.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/audio/vehicles/car/car_brake.wav"
|
||||||
|
dest_files=["res://.godot/imported/car_brake.wav-359538a9b1ba4240ae07e54477629dbb.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_mode=0
|
||||||
|
edit/loop_begin=0
|
||||||
|
edit/loop_end=-1
|
||||||
|
compress/mode=2
|
||||||
BIN
game/assets/audio/vehicles/car/car_engine_accel_loop.wav
Normal file
BIN
game/assets/audio/vehicles/car/car_engine_accel_loop.wav
Normal file
Binary file not shown.
@ -0,0 +1,24 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamWAV"
|
||||||
|
uid="uid://dlg100ft5f2jy"
|
||||||
|
path="res://.godot/imported/car_engine_accel_loop.wav-25b55bfc6e1d41b17513ac3dd914f463.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/audio/vehicles/car/car_engine_accel_loop.wav"
|
||||||
|
dest_files=["res://.godot/imported/car_engine_accel_loop.wav-25b55bfc6e1d41b17513ac3dd914f463.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_mode=1
|
||||||
|
edit/loop_begin=0
|
||||||
|
edit/loop_end=-1
|
||||||
|
compress/mode=2
|
||||||
BIN
game/assets/audio/vehicles/car/car_engine_drive_loop.wav
Normal file
BIN
game/assets/audio/vehicles/car/car_engine_drive_loop.wav
Normal file
Binary file not shown.
@ -0,0 +1,24 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamWAV"
|
||||||
|
uid="uid://cljhbkwcswalc"
|
||||||
|
path="res://.godot/imported/car_engine_drive_loop.wav-be0d54cca48b174deaff89a90d5364c3.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/audio/vehicles/car/car_engine_drive_loop.wav"
|
||||||
|
dest_files=["res://.godot/imported/car_engine_drive_loop.wav-be0d54cca48b174deaff89a90d5364c3.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_mode=1
|
||||||
|
edit/loop_begin=0
|
||||||
|
edit/loop_end=-1
|
||||||
|
compress/mode=2
|
||||||
BIN
game/assets/audio/vehicles/car/car_engine_idle_loop.wav
Normal file
BIN
game/assets/audio/vehicles/car/car_engine_idle_loop.wav
Normal file
Binary file not shown.
@ -0,0 +1,24 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamWAV"
|
||||||
|
uid="uid://c28v6t3txgn8w"
|
||||||
|
path="res://.godot/imported/car_engine_idle_loop.wav-56323a2fbc32742f6519b3630f97c275.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/audio/vehicles/car/car_engine_idle_loop.wav"
|
||||||
|
dest_files=["res://.godot/imported/car_engine_idle_loop.wav-56323a2fbc32742f6519b3630f97c275.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_mode=1
|
||||||
|
edit/loop_begin=0
|
||||||
|
edit/loop_end=-1
|
||||||
|
compress/mode=2
|
||||||
BIN
game/assets/audio/vehicles/car/car_enter.wav
Normal file
BIN
game/assets/audio/vehicles/car/car_enter.wav
Normal file
Binary file not shown.
24
game/assets/audio/vehicles/car/car_enter.wav.import
Normal file
24
game/assets/audio/vehicles/car/car_enter.wav.import
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamWAV"
|
||||||
|
uid="uid://bhmyl3ie10u53"
|
||||||
|
path="res://.godot/imported/car_enter.wav-aeff3918a465be3f557bb484cf84ed62.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/audio/vehicles/car/car_enter.wav"
|
||||||
|
dest_files=["res://.godot/imported/car_enter.wav-aeff3918a465be3f557bb484cf84ed62.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_mode=0
|
||||||
|
edit/loop_begin=0
|
||||||
|
edit/loop_end=-1
|
||||||
|
compress/mode=2
|
||||||
BIN
game/assets/audio/vehicles/car/car_exit.wav
Normal file
BIN
game/assets/audio/vehicles/car/car_exit.wav
Normal file
Binary file not shown.
24
game/assets/audio/vehicles/car/car_exit.wav.import
Normal file
24
game/assets/audio/vehicles/car/car_exit.wav.import
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamWAV"
|
||||||
|
uid="uid://bngm3s2yq2xwi"
|
||||||
|
path="res://.godot/imported/car_exit.wav-f78ac0b868ae38aeb13d15881f6c3491.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/audio/vehicles/car/car_exit.wav"
|
||||||
|
dest_files=["res://.godot/imported/car_exit.wav-f78ac0b868ae38aeb13d15881f6c3491.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_mode=0
|
||||||
|
edit/loop_begin=0
|
||||||
|
edit/loop_end=-1
|
||||||
|
compress/mode=2
|
||||||
BIN
game/assets/audio/vehicles/car/car_hit.wav
Normal file
BIN
game/assets/audio/vehicles/car/car_hit.wav
Normal file
Binary file not shown.
24
game/assets/audio/vehicles/car/car_hit.wav.import
Normal file
24
game/assets/audio/vehicles/car/car_hit.wav.import
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamWAV"
|
||||||
|
uid="uid://bq2d35mekg4il"
|
||||||
|
path="res://.godot/imported/car_hit.wav-5f5ca7b335ab69bea356887a03a1eacc.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/audio/vehicles/car/car_hit.wav"
|
||||||
|
dest_files=["res://.godot/imported/car_hit.wav-5f5ca7b335ab69bea356887a03a1eacc.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_mode=0
|
||||||
|
edit/loop_begin=0
|
||||||
|
edit/loop_end=-1
|
||||||
|
compress/mode=2
|
||||||
BIN
game/assets/audio/vehicles/car/car_horn.wav
Normal file
BIN
game/assets/audio/vehicles/car/car_horn.wav
Normal file
Binary file not shown.
24
game/assets/audio/vehicles/car/car_horn.wav.import
Normal file
24
game/assets/audio/vehicles/car/car_horn.wav.import
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamWAV"
|
||||||
|
uid="uid://y38ybkt3uxik"
|
||||||
|
path="res://.godot/imported/car_horn.wav-4f978ca1d198f5c6c4a5fcfab9ca1ccc.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/audio/vehicles/car/car_horn.wav"
|
||||||
|
dest_files=["res://.godot/imported/car_horn.wav-4f978ca1d198f5c6c4a5fcfab9ca1ccc.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_mode=0
|
||||||
|
edit/loop_begin=0
|
||||||
|
edit/loop_end=-1
|
||||||
|
compress/mode=2
|
||||||
@ -12,14 +12,28 @@ extends RigidBody3D
|
|||||||
@export var exit_path: NodePath
|
@export var exit_path: NodePath
|
||||||
@export var camera_path: NodePath
|
@export var camera_path: NodePath
|
||||||
@export var interact_area_path: NodePath
|
@export var interact_area_path: NodePath
|
||||||
|
@export var engine_audio_fade_speed: float = 8.0
|
||||||
|
@export var hit_sound_cooldown: float = 0.25
|
||||||
|
|
||||||
@onready var seat: Node3D = get_node(seat_path) if seat_path != NodePath("") else null
|
@onready var seat: Node3D = get_node(seat_path) if seat_path != NodePath("") else null
|
||||||
@onready var exit_point: Node3D = get_node(exit_path) if exit_path != NodePath("") else null
|
@onready var exit_point: Node3D = get_node(exit_path) if exit_path != NodePath("") else null
|
||||||
@onready var car_camera: Camera3D = get_node(camera_path) if camera_path != NodePath("") else null
|
@onready var car_camera: Camera3D = get_node(camera_path) if camera_path != NodePath("") else null
|
||||||
@onready var interact_area: Area3D = get_node(interact_area_path) if interact_area_path != NodePath("") else null
|
@onready var interact_area: Area3D = get_node(interact_area_path) if interact_area_path != NodePath("") else null
|
||||||
|
@onready var engine_idle_audio: AudioStreamPlayer3D = get_node_or_null("Audio/EngineIdle")
|
||||||
|
@onready var engine_drive_audio: AudioStreamPlayer3D = get_node_or_null("Audio/EngineDrive")
|
||||||
|
@onready var engine_accel_audio: AudioStreamPlayer3D = get_node_or_null("Audio/EngineAccel")
|
||||||
|
@onready var enter_audio: AudioStreamPlayer3D = get_node_or_null("Audio/Enter")
|
||||||
|
@onready var exit_audio: AudioStreamPlayer3D = get_node_or_null("Audio/Exit")
|
||||||
|
@onready var brake_audio: AudioStreamPlayer3D = get_node_or_null("Audio/Brake")
|
||||||
|
@onready var hit_audio: AudioStreamPlayer3D = get_node_or_null("Audio/Hit")
|
||||||
|
|
||||||
var _nearby_driver: Node = null
|
var _nearby_driver: Node = null
|
||||||
var _driver: Node = null
|
var _driver: Node = null
|
||||||
|
var _speed_factor: float = 0.0
|
||||||
|
var _throttle_input: float = 0.0
|
||||||
|
var _braking: bool = false
|
||||||
|
var _was_braking: bool = false
|
||||||
|
var _hit_sound_time_left: float = 0.0
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
add_to_group("vehicle")
|
add_to_group("vehicle")
|
||||||
@ -33,17 +47,23 @@ func _ready() -> void:
|
|||||||
contact_monitor = true
|
contact_monitor = true
|
||||||
max_contacts_reported = 8
|
max_contacts_reported = 8
|
||||||
|
|
||||||
func _process(_delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
if _driver == null and _nearby_driver != null and Input.is_action_just_pressed("interact"):
|
if _driver == null and _nearby_driver != null and Input.is_action_just_pressed("interact"):
|
||||||
_enter_vehicle(_nearby_driver)
|
_enter_vehicle(_nearby_driver)
|
||||||
elif _driver != null and Input.is_action_just_pressed("interact"):
|
elif _driver != null and Input.is_action_just_pressed("interact"):
|
||||||
_exit_vehicle()
|
_exit_vehicle()
|
||||||
|
_update_audio(delta)
|
||||||
|
_hit_sound_time_left = maxf(0.0, _hit_sound_time_left - delta)
|
||||||
|
|
||||||
func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
||||||
if _driver == null:
|
if _driver == null:
|
||||||
|
_speed_factor = 0.0
|
||||||
|
_throttle_input = 0.0
|
||||||
|
_braking = false
|
||||||
return
|
return
|
||||||
|
|
||||||
var input2v := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
var input2v := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||||
|
_throttle_input = input2v.y
|
||||||
var forward := global_transform.basis.z
|
var forward := global_transform.basis.z
|
||||||
forward.y = 0.0
|
forward.y = 0.0
|
||||||
forward = forward.normalized()
|
forward = forward.normalized()
|
||||||
@ -51,6 +71,9 @@ func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
|||||||
var current_speed := linear_velocity.dot(forward)
|
var current_speed := linear_velocity.dot(forward)
|
||||||
var target_speed := input2v.y * drive_speed
|
var target_speed := input2v.y * drive_speed
|
||||||
var accel := drive_accel if abs(input2v.y) > 0.01 else brake_strength
|
var accel := drive_accel if abs(input2v.y) > 0.01 else brake_strength
|
||||||
|
var is_coasting_brake: bool = abs(input2v.y) <= 0.01 and abs(current_speed) > drive_speed * 0.35
|
||||||
|
var is_reverse_brake: bool = abs(input2v.y) > 0.01 and signf(input2v.y) != signf(current_speed) and abs(current_speed) > drive_speed * 0.25
|
||||||
|
_braking = is_coasting_brake or is_reverse_brake
|
||||||
var new_forward_speed := move_toward(current_speed, target_speed, accel * state.step)
|
var new_forward_speed := move_toward(current_speed, target_speed, accel * state.step)
|
||||||
var forward_vel := forward * new_forward_speed
|
var forward_vel := forward * new_forward_speed
|
||||||
var lateral_vel := linear_velocity - (forward * current_speed)
|
var lateral_vel := linear_velocity - (forward * current_speed)
|
||||||
@ -58,6 +81,7 @@ func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
|||||||
linear_velocity = forward_vel + lateral_vel
|
linear_velocity = forward_vel + lateral_vel
|
||||||
|
|
||||||
var speed_factor: float = clamp(abs(new_forward_speed) / drive_speed, 0.0, 1.0)
|
var speed_factor: float = clamp(abs(new_forward_speed) / drive_speed, 0.0, 1.0)
|
||||||
|
_speed_factor = speed_factor
|
||||||
var turn_input := input2v.x
|
var turn_input := input2v.x
|
||||||
if new_forward_speed < -0.1:
|
if new_forward_speed < -0.1:
|
||||||
turn_input = -turn_input
|
turn_input = -turn_input
|
||||||
@ -80,12 +104,15 @@ func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
|||||||
launch_dir = normal_world if normal_world.length() > 0.001 else forward.normalized()
|
launch_dir = normal_world if normal_world.length() > 0.001 else forward.normalized()
|
||||||
var impulse := launch_dir * (launch_impulse * speed_factor) + Vector3.UP * launch_up_impulse
|
var impulse := launch_dir * (launch_impulse * speed_factor) + Vector3.UP * launch_up_impulse
|
||||||
(collider as RigidBody3D).apply_central_impulse(impulse)
|
(collider as RigidBody3D).apply_central_impulse(impulse)
|
||||||
|
_play_hit_audio(speed_factor)
|
||||||
|
|
||||||
func _enter_vehicle(player: Node) -> void:
|
func _enter_vehicle(player: Node) -> void:
|
||||||
if seat == null:
|
if seat == null:
|
||||||
return
|
return
|
||||||
_driver = player
|
_driver = player
|
||||||
player.call("enter_vehicle", self, seat, car_camera)
|
player.call("enter_vehicle", self, seat, car_camera)
|
||||||
|
_play_one_shot(enter_audio)
|
||||||
|
_start_engine_audio()
|
||||||
if car_camera:
|
if car_camera:
|
||||||
car_camera.current = true
|
car_camera.current = true
|
||||||
|
|
||||||
@ -94,6 +121,10 @@ func _exit_vehicle() -> void:
|
|||||||
return
|
return
|
||||||
_driver.call("exit_vehicle", exit_point, car_camera)
|
_driver.call("exit_vehicle", exit_point, car_camera)
|
||||||
_driver = null
|
_driver = null
|
||||||
|
_speed_factor = 0.0
|
||||||
|
_throttle_input = 0.0
|
||||||
|
_braking = false
|
||||||
|
_play_one_shot(exit_audio)
|
||||||
if car_camera:
|
if car_camera:
|
||||||
car_camera.current = false
|
car_camera.current = false
|
||||||
|
|
||||||
@ -104,3 +135,55 @@ func _on_interact_body_entered(body: Node) -> void:
|
|||||||
func _on_interact_body_exited(body: Node) -> void:
|
func _on_interact_body_exited(body: Node) -> void:
|
||||||
if body == _nearby_driver:
|
if body == _nearby_driver:
|
||||||
_nearby_driver = null
|
_nearby_driver = null
|
||||||
|
|
||||||
|
func _start_engine_audio() -> void:
|
||||||
|
_start_engine_player(engine_idle_audio)
|
||||||
|
_start_engine_player(engine_drive_audio)
|
||||||
|
_start_engine_player(engine_accel_audio)
|
||||||
|
|
||||||
|
func _update_audio(delta: float) -> void:
|
||||||
|
if _driver != null:
|
||||||
|
_start_engine_audio()
|
||||||
|
|
||||||
|
var active: bool = _driver != null
|
||||||
|
var throttle_weight: float = clamp(abs(_throttle_input), 0.0, 1.0)
|
||||||
|
var accel_weight: float = throttle_weight * clamp(_speed_factor * 1.25, 0.0, 1.0)
|
||||||
|
var drive_weight: float = clamp(_speed_factor * 1.25, 0.0, 1.0) * (1.0 - accel_weight * 0.45)
|
||||||
|
var idle_weight: float = 0.9 - clamp(_speed_factor * 1.35, 0.0, 0.72)
|
||||||
|
|
||||||
|
_set_engine_player(engine_idle_audio, idle_weight if active else 0.0, 0.86 + _speed_factor * 0.18, delta)
|
||||||
|
_set_engine_player(engine_drive_audio, drive_weight if active else 0.0, 0.92 + _speed_factor * 0.35, delta)
|
||||||
|
_set_engine_player(engine_accel_audio, accel_weight if active else 0.0, 0.96 + _speed_factor * 0.5, delta)
|
||||||
|
|
||||||
|
if _braking and not _was_braking:
|
||||||
|
_play_one_shot(brake_audio)
|
||||||
|
_was_braking = _braking
|
||||||
|
|
||||||
|
func _set_engine_player(player: AudioStreamPlayer3D, weight: float, pitch: float, delta: float) -> void:
|
||||||
|
if player == null:
|
||||||
|
return
|
||||||
|
var target_volume: float = linear_to_db(maxf(weight, 0.0001)) - 2.0
|
||||||
|
if weight <= 0.001:
|
||||||
|
target_volume = -80.0
|
||||||
|
player.volume_db = move_toward(player.volume_db, target_volume, engine_audio_fade_speed * 10.0 * delta)
|
||||||
|
player.pitch_scale = move_toward(player.pitch_scale, pitch, engine_audio_fade_speed * delta)
|
||||||
|
|
||||||
|
func _start_engine_player(player: AudioStreamPlayer3D) -> void:
|
||||||
|
if player == null or player.playing:
|
||||||
|
return
|
||||||
|
player.play()
|
||||||
|
|
||||||
|
func _play_one_shot(player: AudioStreamPlayer3D) -> void:
|
||||||
|
if player == null:
|
||||||
|
return
|
||||||
|
player.stop()
|
||||||
|
player.play()
|
||||||
|
|
||||||
|
func _play_hit_audio(speed_factor: float) -> void:
|
||||||
|
if hit_audio == null or _hit_sound_time_left > 0.0:
|
||||||
|
return
|
||||||
|
hit_audio.pitch_scale = randf_range(0.92, 1.08)
|
||||||
|
var hit_volume: float = clamp(speed_factor, 0.25, 1.0)
|
||||||
|
hit_audio.volume_db = linear_to_db(hit_volume) - 3.0
|
||||||
|
hit_audio.play()
|
||||||
|
_hit_sound_time_left = hit_sound_cooldown
|
||||||
|
|||||||
@ -3,6 +3,13 @@
|
|||||||
[ext_resource type="Script" uid="uid://4qf5yinepytc" path="res://scenes/Vehicles/car.gd" id="1_kbd20"]
|
[ext_resource type="Script" uid="uid://4qf5yinepytc" path="res://scenes/Vehicles/car.gd" id="1_kbd20"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dvgiooankbnw3" path="res://assets/models/vehicles/doge/doge-body.glb" id="2_doge_body"]
|
[ext_resource type="PackedScene" uid="uid://dvgiooankbnw3" path="res://assets/models/vehicles/doge/doge-body.glb" id="2_doge_body"]
|
||||||
[ext_resource type="PackedScene" uid="uid://civr7hlbf2kqb" path="res://assets/models/vehicles/doge/Wheel.glb" id="3_doge_wheel"]
|
[ext_resource type="PackedScene" uid="uid://civr7hlbf2kqb" path="res://assets/models/vehicles/doge/Wheel.glb" id="3_doge_wheel"]
|
||||||
|
[ext_resource type="AudioStream" path="res://assets/audio/vehicles/car/car_engine_idle_loop.wav" id="4_engine_idle"]
|
||||||
|
[ext_resource type="AudioStream" path="res://assets/audio/vehicles/car/car_engine_drive_loop.wav" id="5_engine_drive"]
|
||||||
|
[ext_resource type="AudioStream" path="res://assets/audio/vehicles/car/car_engine_accel_loop.wav" id="6_engine_accel"]
|
||||||
|
[ext_resource type="AudioStream" path="res://assets/audio/vehicles/car/car_enter.wav" id="7_enter"]
|
||||||
|
[ext_resource type="AudioStream" path="res://assets/audio/vehicles/car/car_exit.wav" id="8_exit"]
|
||||||
|
[ext_resource type="AudioStream" path="res://assets/audio/vehicles/car/car_brake.wav" id="9_brake"]
|
||||||
|
[ext_resource type="AudioStream" path="res://assets/audio/vehicles/car/car_hit.wav" id="10_hit"]
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_body_center"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_body_center"]
|
||||||
size = Vector3(1.9717, 1, 2.08592)
|
size = Vector3(1.9717, 1, 2.08592)
|
||||||
@ -71,3 +78,54 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.3, 0, 0)
|
|||||||
|
|
||||||
[node name="CarCamera" type="Camera3D" parent="." unique_id=1783366397]
|
[node name="CarCamera" type="Camera3D" parent="." unique_id=1783366397]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 4.2)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 4.2)
|
||||||
|
|
||||||
|
[node name="Audio" type="Node3D" parent="."]
|
||||||
|
|
||||||
|
[node name="EngineIdle" type="AudioStreamPlayer3D" parent="Audio"]
|
||||||
|
stream = ExtResource("4_engine_idle")
|
||||||
|
volume_db = -80.0
|
||||||
|
bus = &"SFX"
|
||||||
|
unit_size = 6.0
|
||||||
|
max_distance = 45.0
|
||||||
|
|
||||||
|
[node name="EngineDrive" type="AudioStreamPlayer3D" parent="Audio"]
|
||||||
|
stream = ExtResource("5_engine_drive")
|
||||||
|
volume_db = -80.0
|
||||||
|
bus = &"SFX"
|
||||||
|
unit_size = 6.0
|
||||||
|
max_distance = 55.0
|
||||||
|
|
||||||
|
[node name="EngineAccel" type="AudioStreamPlayer3D" parent="Audio"]
|
||||||
|
stream = ExtResource("6_engine_accel")
|
||||||
|
volume_db = -80.0
|
||||||
|
bus = &"SFX"
|
||||||
|
unit_size = 6.0
|
||||||
|
max_distance = 60.0
|
||||||
|
|
||||||
|
[node name="Enter" type="AudioStreamPlayer3D" parent="Audio"]
|
||||||
|
stream = ExtResource("7_enter")
|
||||||
|
volume_db = -7.0
|
||||||
|
bus = &"SFX"
|
||||||
|
unit_size = 5.0
|
||||||
|
max_distance = 25.0
|
||||||
|
|
||||||
|
[node name="Exit" type="AudioStreamPlayer3D" parent="Audio"]
|
||||||
|
stream = ExtResource("8_exit")
|
||||||
|
volume_db = -7.0
|
||||||
|
bus = &"SFX"
|
||||||
|
unit_size = 5.0
|
||||||
|
max_distance = 25.0
|
||||||
|
|
||||||
|
[node name="Brake" type="AudioStreamPlayer3D" parent="Audio"]
|
||||||
|
stream = ExtResource("9_brake")
|
||||||
|
volume_db = -5.0
|
||||||
|
bus = &"SFX"
|
||||||
|
unit_size = 5.0
|
||||||
|
max_distance = 35.0
|
||||||
|
|
||||||
|
[node name="Hit" type="AudioStreamPlayer3D" parent="Audio"]
|
||||||
|
stream = ExtResource("10_hit")
|
||||||
|
volume_db = -6.0
|
||||||
|
bus = &"SFX"
|
||||||
|
unit_size = 7.0
|
||||||
|
max_distance = 45.0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user