How to create the motor sound for a car game (Godot 4)
ฝัง
- เผยแพร่เมื่อ 11 ม.ค. 2025
- In this video I'll show you how to mix three sine waves to create the motor sound.
Credits:
"Low Poly Car - Chrysler Saratoga 1960" (skfb.ly/o87Ow) by ROH3D is licensed under Creative Commons Attribution (creativecommons....
"CCity Building Set 1" (skfb.ly/LpSC) by Neberkenezer is licensed under Creative Commons Attribution (creativecommons....
www.audacityte...
godotengine.org/
fonts.google.com/
obsproject.com/
www.shotcut.org/
Game looks cool, reminds me of old Driver games from PS1
THANKS I GIVE YOU A HUGE LIKE
really nice demo man
1960 Chrysler 300 nice choice of car
It is remarkable how good the car sounds at the end when I realized that the only sound that you used was a round sinewave.
I have an observations about the controls, in a normal car, you would gain more grip when you release the throttle but in your Game It feels weird because It looks like you lose some grip when youre not throtteing. But everything else is very good job
I subscribed to your Channel
Thanks! In terms of sound this is no coincidence, reference is Fourier synthesis. However exceeding the signal limits also plays a role here.
I would like to learn to code engine sounds into my game, is there a tutorial for Godot that you recommend?
@@Big_Theft_Auto I was just using the documentation (it is good!). I'm using two AudioStreamPlayer3D nodes. One for accelerating and one for decelerating. I use the same pitch (pitch_scale) for both of them. The pitch depends on the speed of the car. The volume (volume_db) is different for accelerating and decelerating. When accelerating the on-sound is loud and the off-sound is quiet and vice versa. Very simple.
@@tomaga4995 clever stuff, i'm going to try but with a recording of a real engine and see if it sounds as good, if it doesn't then i'll just do exactly what you did 😅 😂
Nice
Nice tutorial
Thank you!
Thanks for sharing.
good tutorial + hitting the best drifts haha good job man
Thank you!
how to i get the sounds to play?? not much of a tutorial for godot, mainly just audacity 😞
i just made my own, not as good as the one in the video but it works!
(you must use a VehicleBody3D node)
extends VehicleBody3D
const MAX_STEER = 0.8
const ENGINE_POWER = 500
const MAX_SPEED = 100 # Adjust MAX_SPEED according to your needs
@onready var camera_pivot = $CameraPivot
@onready var camera_3d = $CameraPivot/Camera3D
@onready var reverse_camera = $CameraPivot/ReverseCamera
var look_at
var engine_sound_player : AudioStreamPlayer3D
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
look_at = global_position
engine_sound_player = $CameraPivot/AudioStreamPlayer3D2
engine_sound_player.play()
func _physics_process(delta):
steering = move_toward(steering, Input.get_axis("ui_right", "ui_left") * MAX_STEER, delta * 3.5)
engine_force = Input.get_axis("ui_down", "ui_up") * ENGINE_POWER
# Adjust these parameters for faster and higher pitch increase
var pitch_increase_speed = 5.0
var max_pitch = 10.0
# Calculate engine sound with faster and higher pitch increase
var engine_sound = linear_velocity.length() / MAX_SPEED * pitch_increase_speed + 1
engine_sound = min(engine_sound, max_pitch)
engine_sound_player.pitch_scale = engine_sound
camera_pivot.global_position = camera_pivot.global_position.lerp(global_position, delta * 20.0)
camera_pivot.transform = camera_pivot.transform.interpolate_with(transform, delta * 5.0)
look_at = look_at.lerp(global_position + linear_velocity, delta * 5.0)
camera_3d.look_at(look_at)
reverse_camera.look_at(look_at)
_check_camera_switch()
func _check_camera_switch():
if linear_velocity.dot(transform.basis.z) > -2:
camera_3d.current = true
else:
reverse_camera.current = true
@@SOS_Studios Great code! Thanks for the help!
@@SOS_Studios thank you
car script tutorial
A turioal on how to make the buildings?
I didn't make them myself. They are from sketchfab (link in the description). I then simply placed a few of them next to each other.
great job, but the car feels very slipery right? it shoudn drift that much lol
Heavy 50s cars kinda do that to some extent tbh xD
how did u code the sounds to the car?
I've created two AudioStreamPlayer3D. One for acceleration and one for deceleration. I assign the wav file for acceleration (on.wav) to one AudioStreamPlayer3D and the off.wav file to the other. In the code, I set pitch and volume for both AudioStreamPlayer3D - depending on whether I am accelerating or decelerating (and of course how fast the car is currently traveling).