- Home /
Audio mutes when tracker is lost
What I'm looking for is basically explained in the question.
I've got some audio that I want to mute (not stop/pause) when the AR tracker is lost then unmute when it is found again. I know this will involve coding, could anyone head me in the right direction?
Thanks
AudioSource yourSourceFor$$anonymous$$usic;
if( found)
yourSourceFor$$anonymous$$usic.Play();
if( lost)
yourSourceFor$$anonymous$$usic.Stop();
Answer by oliver-jones · Sep 25, 2013 at 05:41 PM
It's hard to help when you haven't posted any code by the AR. But I'm guessing the AR will have an event thats called when the tracker is lost and found.
So you want to do something like this:
if(trackerFound == true){
audio.mute = false;
}
else{
audio.mute = true;
}
And attach this to the Game Object that has the audio source on it. This wont work if you just copy and paste, as trackerFound is just a made up event. You need to check inside your AR script for an event that gets called every time the tracker is lost/found.
Like I said, post some of the AR code up and we'll be able to help. Also, what AR plugin are you using? Vuforia?
Thanks, works a treat! Just as reference for anyone else wanting to do it, the Vuforia AR part of the code goes something like this:
private void OnTrackingFound()
{
audio.mute = false;
}
private void OnTrackingLost()
{
audio.mute = true;
}
And that goes in the Default Trackable Event Handler (Script)
Answer by PTerto · Sep 25, 2013 at 06:01 PM
Well, why don't u set the AudioSource Volume to 0 when the tracker is missing?
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Atmosphere sounds triggered by invisible blocks? (JS) 1 Answer
Sprinting Audio Problem 1 Answer
Mute Unity Ads in code? 2 Answers
Card matching game 1 Answer