Immersion Starts with Sound
Objective: Learn how to add and use an audio system in our game.
We can notice that our Main Camera object has an Audio Listener component, meaning it can pick up sounds. In order for us to manage the sound of our game better, we are going to use an Audio Manager, who is going to be responsible for it.

Now we are going to create the object who is going to be responsible for our Background music, which is going to be inside our Audio Manager.

Now, when we start our game, we have a background music.
But this is not the only moment when we need sound in our game, right ? So let’s add the sound of our lasers being shot by our player!
[SerializeField] private AudioClip _laserSound;
private AudioSource _audioSource;
private void Start()
{
_audioSource = GetComponent<AudioSource>();
if (_audioSource == null)
{
Debug.LogError("Audio Source is NULL on the Player");
}
else
{
_audioSource.clip = _laserSoundClip;
}
}

All we are doing is creating the Audio Source on our player, assigning it to a variable, making sure the player has a reference of the laser sound clip, and that clips is immediately attached to our Audio Source on Void Start.
We can change the volume if we want, so you can test how loud the laser should be, but with this, all we are doing is assigning the laser sound clip to our player when the game starts. If we wanted, we could change clips to play during our gameplay.
And there you have it, now we have both a background music, and laser sounds coming from our player. Its sounding like a real videogame!