Question by
gustavodiniz-b · May 03, 2018 at 01:01 PM ·
audioelse
having problem with 'else' did i put it in the wrong place?
private void EngineAudio() {
if (Mathf.Abs(m_MovementInputValue) < 0.1f && Mathf.Abs(m_TurnInputValue) < 0.1f);
{
if (m_MovementAudio.clip == m_EngineDriving)
{
m_MovementAudio.clip = m_EngineIdling;
m_MovementAudio.pitch = Random.Range(m_OriginalPitch - m_PitchRange, m_OriginalPitch + m_PitchRange);
m_MovementAudio.Play();
}
}
else
{
if (m_MovementAudio.clip == m_EngineIdling)
{
m_MovementAudio.clip = m_EngineDriving;
m_MovementAudio.pitch = Random.Range(m_OriginalPitch - m_PitchRange, m_OriginalPitch + m_PitchRange);
m_MovementAudio.Play();
}
}
}
Comment
Answer by Harinezumi · May 03, 2018 at 01:50 PM
There is a ;
after the first if
, so it is already closed, which means your else
is positioned "illegally". Remove that ;
, and the syntax will be fine.
Your answer
![](https://koobas.hobune.stream/wayback/20220612161949im_/https://answers.unity.com/themes/thub/images/avi.jpg)