- Home /
The question is answered, right answer could not be accepted because the accept button is not there. fffMalzbier gave the correct answer.
Unity 5: AudioLowPassfilter.cutoffFrequency not doing anything
Hello, today i have a script command for you, that doesn't work at all.
I want to change the cutoff frequency of an AudioLowPassFilter via script. It doesn't work.
It only changes if I do it manually in the inspector while the game is running.
Code:
AudioLowPassFilter filter;
public bool bool1;
void Start()
{
filter = GameObject.Find("GameLogic").getComponent<AudioLowPassFilter>();
}
void Update()
{
if(bool1)
{
filter.cutoffFrequency = 5000f;
}
else
{
filter.cutoffFrequency = 100f;
}
}
I read in one older post that there was a bug where the value DID change, but it was not updated in the inspector.
Well, it does not work completely as of today. I'm using Unity 5.
That is very very very strange. I read your comment and added:
print(filter.cuttoffFrequency);
Into the Update function. It works now. :|
I don't know why and I certainly don't want to know :P Thanks for sharing your experience $$anonymous$$alzbier, maybe convert your comment into an answer so I can mark it as solved by that answer?
Since the time I posted this question it has never happened again so I guess it was a 1:1.000.000 bug or patched in the meantime. Thank you.
Answer by fffMalzbier · Mar 12, 2015 at 09:37 AM
I can observe that the cutoffFrequency actually changes but the inspector seems to not display the correct value at all.
You can add this to you update function to see the current value in the console log. Debug.Log (filter.cutoffFrequency);
Alternately you can set the inspector to debug mode (over the menu besides the small lock symbol) to see that the value changes. Looks like the inspector for the AudioLowPassfilter is just broken :(
Follow this Question
Related Questions
Audio Low Pass Filter Not Working 1 Answer
Where is the audio low pass rolloff curve GUI? (Unity 3) 1 Answer
Audio Analysis: isolating frequency values 1 Answer
Procedural native audio synthesis with OnAudioFilterRead 1 Answer
How do I manipulate 3 audio with 3 slider audio filter each at once? 0 Answers