Questions tagged [audio-source]

This tag will use to ask about the questions related to audio source component of unity3d game engine. Audio source is one of the basic component of unity for enabling sounds in game. Its allow sounds playback in 3D environment.

An AudioSource is attached to a GameObject for playing back sounds in a 3D environment. In order to play 3D sounds you also need to have an AudioListener. The AudioListener is normally attached to the camera you want to use. Whether sounds are played in 3D or 2D is determined by AudioImporter settings [More].


Related tags

52 questions
0
votes
2 answers

How to detect Unity AudioSource volume change?

I am using Unity AudioSource. It is easy to get and change the volume by accessing AudioSource.volume as explained here https://docs.unity3d.com/ScriptReference/AudioSource-volume.html. How do I detect the volume change? Is there any callback or…
gameon67
  • 3,981
  • 5
  • 35
  • 61
0
votes
1 answer

Change Song on Button Press

I am trying to create a Music button and each time this button is pressed the song will change. In total, I have 4 songs. So, when the button is pressed the 1st time, song 1 will play. When the button is pressed for the 2nd time, song 2 will play…
Z.Mizzi
  • 13
  • 2
0
votes
0 answers

Unity Audio is slightly delayed

I want to make a game based on rythm and music. But when prototyping i got stuck at one problem When i click the mouse, a sound should play instantly. I analysed a recording - and the sound is about 0.1 second delayed. i also tried just visually,…
CherryFake
  • 125
  • 1
  • 10
0
votes
1 answer

AudioSource continues playing old clip after new clip assigned

My game is playing background music and I want to switch it based on game attributes. Here is my solution: AudioSource audioSource; [SerializeField] AudioClip audioClipLowZombies; [SerializeField] AudioClip audioClipMediumZombies; [SerializeField]…
ChrisPBcn
  • 57
  • 1
  • 5
0
votes
1 answer

Why is this audio source not playing anything?

Im trying to write a script where the audio source plays an audioclip array with 4 sounds in it. The sounds are gonna be played faster and louder when my character is sprinting and quieter and slower when my character is crouching. My problem is…
0
votes
1 answer

How to change DontDestroyOnLoad'ed AudioSource's AudioClip on a new scene?

I have couple of different scenes and I would like to play different tunes in specific scenes. I created a game object and attached an audio clip and a script. The script basically keeps Unity away from destroying. So it can play on different…
coner
  • 270
  • 7
  • 21
0
votes
1 answer

How do I make an audio source play and then when finished the player detector destroys?

Hello I have a 2d Platformer in Unity and I have this sprite with a box collider that detects if its come into contact with the player, when it does it should play the audio source, pause it when the audio source is done it should resume time and…
Leo Cato
  • 3
  • 1
0
votes
0 answers

Unity audio source delayed on Android platforms?

I have just published a 2D ball game using Unity 2019.3.9f1 in google play and I downloaded it on my phone. When I played it, the sound of the ball hitting the wall seemed to to be delayed by a half second. But it works completely fine when I tested…
Jelly Qwerty
  • 317
  • 1
  • 4
  • 13
0
votes
1 answer

How to manage AudioSources at runtime in Unity c#

In a music application in Unity, when you put a fadeout so that the sounds that are being created have no clicking when they stop, all the music that is in the background also enters into the fadeout. I would like to be able to do fadeout without…
Jose
  • 3
  • 1
  • 5
0
votes
1 answer

Unity - Multiple Prefabs with Audio Source

I am using a prefab with an audio source attached to it and is used only if you click on the prefab to play a short sound (click sound). There is a scene that I am using this prefab for ~50 times. There is no problem at all, it works great but I…
Johny
  • 625
  • 2
  • 6
  • 26
0
votes
2 answers

Get current playback time of AudioSource before disabling the object

Is there a way to get the current playback time of an audio played by the audiosource before its parent becomes disabled? I have this gameobject that has audiosource component that play a sound and I want to get the current playback time of the…
unice
  • 2,655
  • 5
  • 43
  • 78
0
votes
1 answer

Same GameObject Two AudioSources Not Playing Their AudioClips - Unity

I was working on 3d runner kind of game so I have attached two AudioSources component within Player GameObject: AudioSource for playing gameplay music AudioSource for playing player collision sound On same Player GameObject, I have assigned two…
Siddharth
  • 4,142
  • 9
  • 44
  • 90
0
votes
1 answer

AudioSource.Play() not working in Enumerator

I have an Enumerator for the effects played when you shoot a gun. It is: private IEnumerator ShotEffect() { gunAudio.Play(); laserLine.enabled = true; yield return shotDuration; laserLine.enabled = false; …
0
votes
1 answer

Unity: Multiple Instances sharing one AudioSource

I am building a simple 2D game, basically a clone of Plants vs. Zombies, for learning purposes. I can add different defenders to my game and I want one of my defenders to play an ongoing sound when it is instantiated in the game. So the sound…
marvinb89
  • 83
  • 9
0
votes
2 answers

Continuous AudioSource in DontDestroyOnLoad GameObject

My game contains multiple scenes and I want play continuous game music between multiple scenes. For this purpose, I have written code like this: public static SoundManager Instance { get { return instance; } } public AudioClip[] levelClips; public…
Siddharth
  • 4,142
  • 9
  • 44
  • 90