How can i mute a specific AudioSource?,How to stop a specific AudioSource from playing?,How to mute a specific AudioSource=
Hi guys, my problem is the following: I imported the car asset from the Import Package menu (standard assets). the car got 4 AudioSource hidden that only start playing when the script is called (which means that i cannot modify it out of the Play Mode). I don't want to hear the car when im far from it... Whenever I try to change it via code: public class RangeBetweenObjects : MonoBehaviour {
public GameObject car;
public GameObject player;
public float Distance_;
void Update()
{
Distance_ = Vector3.Distance(car.transform.position, player.transform.position);
if (Distance_ >= 500)
{
car.GetComponent<AudioSource>().enabled = false;
}
else
{
car.GetComponent<AudioSource>().enabled = true;
}
}
}
it simply just get the 1st AudioSource that finds but I want to mute the 3rd one. Be appreciated if someone could help me get through this problem :( ,Hi guys, my problem is the following: I imported the car asset from the Import Package menu (standard assets). the car got 4 AudioSource hidden that only start playing when the script is called (which means that i cannot modify it out of the Play Mode). I don't want to hear the car when im far from it... Whenever I try to change it via code: public class RangeBetweenObjects : MonoBehaviour {
public GameObject car;
public GameObject player;
public float Distance_;
void Update()
{
Distance_ = Vector3.Distance(car.transform.position, player.transform.position);
if (Distance_ >= 500)
{
car.GetComponent<AudioSource>().enabled = false;
}
else
{
car.GetComponent<AudioSource>().enabled = true;
}
}
}
it simply just get the 1st AudioSource that finds but I want to mute the 3rd one. Be appreciated if someone could help me get through this problem :(
,Hi guys, my problem is the following:
I imported the car asset from the Import Package menu, now i want that when im out of a certain range of that car (with my FPSController), a specific AudioSource to be muted (it means that when im too far from the car i dont want to hear it but when im close to it, i want to hear it). the real problems comes when the AudioSources are not displaying in the script but they do when the script is called (after i press Play). I know which AudioSource i should mute, but it doesn't appear when im out of Play Mode. Does anyone know how to help me?
Your answer
Follow this Question
Related Questions
Sync car audio on UNET network game 0 Answers
car audio pitch help? 1 Answer
I need help getting a sound to play when the E Key is pressed. (E will also load a new Scene). 2 Answers
sound overlap, problems with character controller 0 Answers
How to turn off an audio source when another is being played based on proximity? 0 Answers