- Home /
Audio Script
Hi all. I recently made this audio script: var AudioFile : AudioClip;
function OnTriggerEnter(other:Collider)
{
if(other.tag=="jumpscare")
{
audio.clip = AudioFile;
audio.Play();
}
}
The problem is that it only plays when attached to the PARENT of my character. The parent of my character already has footsteps that play with the audiosource, so when the audio plays, it cuts off this script's audio.
My question: Is there any way to create a new gameobject and attach it to the player but still have this script play audio when it enters the trigger?
Answer by MakeCodeNow · May 29, 2014 at 01:29 AM
Use AudioSource.PlayClipAtPoint or manually create and destroy objects w/ AudioSource components on them for each sound you play. The former is probably much easier for what you need.
Your answer
Follow this Question
Related Questions
Why does the audio sound different than the original ? 0 Answers
Play Audio Sound OnTriggerEnter 2 Answers
How do I prevent audio from restarting if it's being asked to play again? 2 Answers
background Audio plays in Unity Editor but does not play in web player 1 Answer
Triggering audio in javascript 1 Answer