- Home /
Audio mixer Setfloat() method problem in coroutine
I have a problem, when working with this method (AudioMixer.SetFloat()) in a coroutine. Check out this code.
It is increasing exposed audio mixer parameter linearly every 1.5 second. But the code does not work, especially aud.SetFloat(current_pitch);. When I set pitch parameter using this line of code in coroutine it does nothing.
Result of this expression (MIN_PITCH + LevelManager.instance.Current_extra_pitch) / 100.0f; is at the beginning 0.72. Value 0.72 is logged into the console, too. But pitch parameter in audio mixer is not set.
Please help me out, cause I really do not know what is the problem. ;)
[SerializeField] private AudioMixer aud;
private IEnumerator soundtrack_speed_increasing(){
float step;
float current_pitch;
float next_pitch;
step = 2 / (2 / .035f);
current_pitch = (MIN_PITCH + LevelManager.instance.Current_extra_pitch) / 100.0f;
Debug.Log(current_pitch);
aud.SetFloat("Pitch", current_pitch);
while(true){
yield return new WaitForSeconds(1.5f);
next_pitch = (MIN_PITCH + LevelManager.instance.Current_extra_pitch) / 100.0f;
while(current_pitch < next_pitch){
yield return new WaitForSeconds(.035f);;
current_pitch += step;
aud.SetFloat("Pitch", current_pitch);
}
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
StopCourutine not working as expectedd 2 Answers
how to make a coroutine finish first before other coroutine start 1 Answer
Unity Float to db 2 Answers