【Unityゲーム作成講座2】アドベンチャーゲームの作り方#12(サウンドシステム①)【ゆっくり解説】

ハッピーサンライズ
20 Dec 202122:31

Summary

TLDRThis video script offers a detailed tutorial on implementing a sound system in a game. It guides viewers through creating an AudioManager script to manage volume levels for music, sound effects, and system sounds. The tutorial covers attaching an AudioSource component for background music, setting up sliders for volume control within Unity's UI, and writing functions to adjust and play sounds. It also discusses obtaining sound sources from royalty-free platforms like DOVA-SYNDROME and SoundEffect-Lab for battle and normal BGMs, as well as sound effects for various in-game actions. The script concludes with tips on smoothly transitioning between different music tracks for an enhanced gaming experience.

Takeaways

  • 🎧 The video provides a tutorial on how to implement a sound system in a game.
  • 🛠️ It begins by instructing viewers to create an 'Audio Manager' script attached to a main object for managing audio settings.
  • 🔊 The script includes variables for master volume, sound effects volume, system sound volume, and music volume, all initialized to 1.
  • 📐 The master volume is used to adjust the overall volume across four channels: SFX, system sounds, and music.
  • 🔗 The tutorial explains how to protect these values from being changed externally by using properties.
  • 🎵 For managing background music, the script uses an AudioSource component attached to a game object that is created and set as a child of the main object.
  • 📹 The 'Awake' function, which runs once at the start of the game, is used to set up the AudioSource and attach it to a newly created game object.
  • 🔄 The video also covers creating functions to adjust the volume of sound effects and system sounds, as well as the master volume.
  • 📊 Unity's UI system is utilized to create sliders for adjusting volumes, which are scripted to interact with the 'Audio Manager'.
  • 🔗 A 'System UI' script is created to manage the UI components, including a system canvas and volume sliders.
  • 🎶 The tutorial mentions using royalty-free music from DOVA-SYNDROME for background music and sound effects from EffectLab for various in-game actions.

Q & A

  • What is the main topic of the video script?

    -The main topic of the video script is about explaining how to implement a sound system in a game, including creating an AudioManager script and managing audio volumes.

  • What is the purpose of creating an AudioManager script?

    -The AudioManager script is created to manage and control the audio settings within the game, such as adjusting the master volume, sound effects volume, system sounds volume, and background music volume.

  • How does the script handle the initial volume levels for different audio channels?

    -The script initializes the volume levels with public float variables for master volume, sound effects volume, system volume, and music volume, all set to 1, which represents the maximum volume.

  • What is the role of the AudioSource component in the script?

    -The AudioSource component is used to play music by attaching it to a game object. The script also includes a method to automatically generate a game object with an AudioSource component attached when the game starts.

  • How does the script ensure that the AudioManager instance is unique throughout the game?

    -The script uses a singleton pattern for the AudioManager class, ensuring that there is only one instance of the AudioManager throughout the game's lifecycle.

  • What is the purpose of the 'Start' function in the script?

    -The 'Start' function in the script is used to initialize the audio system, such as creating a game object with an AudioSource component and setting it up to play music.

  • How can the volume of the background music be adjusted?

    -The volume of the background music can be adjusted by creating a function that changes the 'musicVol' variable and then sets the AudioSource volume to the product of 'musicVolPercent' and 'MasterVolumePercent'.

  • What is the function of the 'SetVolumeMaster' method in the script?

    -The 'SetVolumeMaster' method is used to adjust the master volume by setting the 'MasterVolume' variable and then updating the AudioSource volume to reflect the new master volume setting.

  • How does the script handle the creation of sliders for volume control?

    -The script creates sliders using Unity's UI system, assigns them to control different audio channels, and links their values to the corresponding volume variables in the AudioManager script.

  • What is the purpose of the 'PlayClipAtPoint' function mentioned in the script?

    -The 'PlayClipAtPoint' function is used to play a sound effect at a specific location in the game world by utilizing the position of a transform and the volume settings.

  • How does the script manage the transition between different background music tracks?

    -The script plays a new music track by attaching it to the dedicated AudioSource for music. It suggests a future improvement to fade out the current music track and fade in the next one for a smooth transition.

Outlines

plate

Esta sección está disponible solo para usuarios con suscripción. Por favor, mejora tu plan para acceder a esta parte.

Mejorar ahora

Mindmap

plate

Esta sección está disponible solo para usuarios con suscripción. Por favor, mejora tu plan para acceder a esta parte.

Mejorar ahora

Keywords

plate

Esta sección está disponible solo para usuarios con suscripción. Por favor, mejora tu plan para acceder a esta parte.

Mejorar ahora

Highlights

plate

Esta sección está disponible solo para usuarios con suscripción. Por favor, mejora tu plan para acceder a esta parte.

Mejorar ahora

Transcripts

plate

Esta sección está disponible solo para usuarios con suscripción. Por favor, mejora tu plan para acceder a esta parte.

Mejorar ahora
Rate This

5.0 / 5 (0 votes)

Etiquetas Relacionadas
Game DevelopmentAudio SystemUnitySound TutorialVolume ControlAudio ManagerScriptingBGMSFXUI Sliders
¿Necesitas un resumen en inglés?