Car controller tutorial #2: Car Engine Audio(realistic) in Unity + GitHub link
Summary
TLDRThis video tutorial demonstrates how to create a realistic engine sound system for a car in a video game, complete with starting, running, and reverse sounds. The guide covers setting up audio sources, looping sounds, and adjusting pitch and volume based on car speed and gas input. It also introduces a script to control the audio, including a rev limiter effect and a starting sound for the engine. Viewers can look forward to a future episode on implementing a gear system for enhanced realism.
Takeaways
- 🔊 The video demonstrates how to create a car sound system with engine sounds for a car game, including start, running, and reverse sounds.
- 🔨 It starts by creating an audio source for the engine and placing it near the engine in the game environment.
- 🔄 The script involves duplicating the audio source to differentiate between idle and running sounds, ensuring they loop for continuous play.
- 📝 A new script called 'engine audio' is created to control the audio behavior based on the car's state and speed.
- 🔊 The script references the car's speed and gas pedal input to adjust the engine sound's volume and pitch dynamically.
- 🚗 The car's speed is calculated by considering the wheel RPM and radius, which is then used to modulate the engine sound.
- 🚦 A max speed variable is introduced to limit the car's speed and prevent the engine sound from exceeding a certain pitch.
- 🎛️ The script includes a function to calculate the speed ratio, which is used to adjust the engine sound based on the gas pedal input and car speed.
- 🔧 A rev limiter effect is implemented to emulate the engine cutting off power at high speeds, using a sine wave oscillation.
- 🚀 The video also covers how to create a starting sound for the engine and transition between different engine states (not running, starting, running).
- 🔁 For reverse sounds, the script checks the direction of the car's movement and adjusts the audio source accordingly to play reverse-specific sounds.
Q & A
What is the purpose of the video?
-The purpose of the video is to demonstrate how to create an engine sound system for a car in a game without gears, featuring starting, running, and reverse sounds.
What are the three main sounds included in the sound system?
-The three main sounds included are the starting sound, running sound, and reverse sound.
How many audio sources are initially created for the engine sound system?
-Initially, two audio sources are created: one for the running sound and one for the idle sound, which is a duplicate of the first.
Why is it necessary to duplicate the audio source for the running sound?
-Duplicating the audio source allows for separate audio clips to be assigned for different engine states, such as running and idle.
What does the 'Loop' checkbox do in the audio source settings?
-The 'Loop' checkbox ensures that the audio clips will repeat continuously, simulating the continuous sound of an engine.
What is the role of the 'engine audio' script in the car?
-The 'engine audio' script is responsible for controlling the audio sources and adjusting the engine sounds based on the car's movement and user input.
How is the car's speed determined in the script?
-The car's speed is determined by calculating the wheel RPM times the wheel's radius, adjusted by the wheel's circumference and divided by 10 for a more manageable number.
What is the purpose of the 'get speed ratio' function in the script?
-The 'get speed ratio' function calculates a value between 0 and 1 that represents the ratio of the current speed to the maximum speed, taking into account the gas pedal input.
How does the script handle the engine sound when the car reaches its top speed?
-The script uses a 'speed clamped' variable to limit the engine sound, preventing it from creating a 'cracking noise' when the car reaches its maximum speed.
What is the rev limiter and how is it implemented in the sound system?
-The rev limiter is a feature that emulates the behavior of a car's engine cutting off power at high RPMs. It is implemented by adding an oscillating sound effect to the running sound pitch based on a set speed ratio threshold.
How does the script handle the starting sound of the engine?
-The script includes a 'StartCoroutine' function that plays the starting sound, sets the engine state to 'starting', and after a delay, changes the state to 'running'.
What adjustments are made to the script to create the reverse sound?
-The script checks the speed sign (positive or negative) to determine if the car is moving forward or in reverse. It then sets the appropriate audio volumes for running and reverse sounds based on this determination.
How does the script ensure the reverse sound only plays when the car is in reverse?
-The script uses a variable to check if the car's wheels are moving backward by taking the absolute value of the speed and comparing it with the sign of the speed.
What is the final step to ensure the reverse sound works correctly?
-The final step is to set the reverse volume to zero when the car is not in reverse and adjust the reverse sound parameters for a more realistic effect.
Outlines
Esta sección está disponible solo para usuarios con suscripción. Por favor, mejora tu plan para acceder a esta parte.
Mejorar ahoraMindmap
Esta sección está disponible solo para usuarios con suscripción. Por favor, mejora tu plan para acceder a esta parte.
Mejorar ahoraKeywords
Esta sección está disponible solo para usuarios con suscripción. Por favor, mejora tu plan para acceder a esta parte.
Mejorar ahoraHighlights
Esta sección está disponible solo para usuarios con suscripción. Por favor, mejora tu plan para acceder a esta parte.
Mejorar ahoraTranscripts
Esta sección está disponible solo para usuarios con suscripción. Por favor, mejora tu plan para acceder a esta parte.
Mejorar ahoraVer Más Videos Relacionados
Playing an Audio File - MetaSound Tutorials for Unreal Engine 5
【Unityゲーム作成講座2】アドベンチャーゲームの作り方#12(サウンドシステム①)【ゆっくり解説】
Cinematic SOUND DESIGN Tutorial for FILMMAKING
MASSIVELY Improve Your Audio with These 4 Effects in Premiere Pro (Tutorial)
UEFN Progress Bar with Only a Material and Verse
How to Screen Record with Internal Audio on QuickTime Player
5.0 / 5 (0 votes)