- Home /
How to play music on collision enter (audio source on player)
Hi everybody ! I want a music to start when the player hit a specific object. I'm using this script :
function OnCollisionEnter (collision : Collision)
{
audio.Play();
}
(whith an audio source on the object)
But everytime the player go away, the music is going lower and lower...
Can you help me ?
How do you mean "the music is going lower and lower"? and which object is the script attached to?
The volume of a 3d sound depends on the distance of the source and the listener. You can mark a sound as 2d in the import settings to prevent this scaling effect.
next time, please format your code correctly (i did it for you this time).
if your problem is solved, please close the question.
Answer by StephanK · Mar 19, 2014 at 04:29 PM
Adding Locksteps answer as an actual answer so this question can be closed.
The volume of a 3d sound depends on the distance of the source and the listener. You can mark a sound as 2d in the import settings to prevent this scaling effect.
Your answer
![](https://koobas.hobune.stream/wayback/20220613132028im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Is it possible to play midi files in unity? 2 Answers
Why Music Player Pause and Stop Buttons Do Not Work As They Should 2 Answers
how to muffle music 3 Answers
Can not play a disabled audio source 2 Answers
How to Trim off Audio Clip's Tail? 1 Answer