Create Immersion with Sounds in Unity

Creating a background sound

Giving our laser a sound using the player script

[SerializeField]
private AudioClip _laserSoundClip;
private AudioSource _audioSource;
_audioSource = GetComponent<AudioSource>();if(_audioSource == null)
{
Debug.LogError("AudioSource on player is NULL");
}
else
{
_audioSource.clip = _laserSoundClip;
}
_audioSource.Play();

Adding sound to the powerups

[SerializeField]
private AudioClip _clip;

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrea Zilio

Andrea Zilio

Passionate Game Developer and Learning Expert. I love to create games and interactive experiences using Unity, Articulate, C#, JavaScript, PHP, HTML, CSS.