- Home /
The question is answered, right answer was accepted
How can I disable Audio Listener? I've tried it all...
Hello, this is my script for the player's camera object:
function Start (){
if (!networkView.isMine){
AudioListener.enabled = false;
camera.enabled = false;
enabled = false;
}
}
It's suppose to disable the audio listener component if it doesn't belong to the player (It's a network game.) I've tried both AudioListener.enabled and audioListener.enabled and neither works. This is the error that the current code returns: Assets/CameraMaster.js(37,31): BCE0020: An instance of type 'UnityEngine.Behaviour' is required to access non static member 'enabled'.
Any help on this would be much appreciated. Thanks in advance.
If it belongs to the player gameObject.AudioListener should do it. If it doesn't belong to the player you will have to 'Find' it.
@meat5000 You mean gameObject.audioListener
. It has to be lower case, because upper-case is reserved for the class, especially because $$anonymous$$onoBehaviour
has the shortcuts for builtin classes. It really should be gameObject.GetComponent(typeof(AudioListener)) as AudioListener
Thanks for help. gameObject.audioListener did the trick, I knew I was just forgetting something small.
Follow this Question
Related Questions
How to reflect / bounce audio off of a 3D Object? 4 Answers
Is it possible to change Audio Manager Volume by script? 1 Answer
I get this error when selecting an audio from the project folder. 0 Answers
Disabling Audio Listener in unity 3d 1 Answer
How can I wrap 3D audio around the edge of a toroid game level? 1 Answer