[Tanks Tutorial] The "engine driving" AudioClip doesn't start
Hi everyone. I'm currently trying to do the "TANKS!" game project (you can find it on Learn > Tutorials > Tanks Tutorial) and I'm at the phase 2 (Tank creation & control).
I managed to successfully move the tank, there is no problem on that point. But I can't do the audio part. (the audio part consists to manage two tank's sounds, one when the tank isn't moving (named engine idle) and one when the tank is moving (named engine driving)
The part's script concerned :
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();
}
}
}
And also the variables conercerned :
public AudioSource m_MovementAudio;
public AudioClip m_EngineIdling;
public AudioClip m_EngineDriving;
public float m_PitchRange = 0.2f;
private string m_MovementAxisName;
private string m_TurnAxisName;
private Rigidbody m_Rigidbody;
private float m_MovementInputValue;
private float m_TurnInputValue;
private float m_OriginalPitch;
m_OriginalPitch is equal to m_MovementAudio.pitch
I checked if there were mistakes in my script, but there is nothing. Then I replaced my code by the code on the tutorial, and it was the same problem : when I start the game, the Tank move correctly, we heard the engine idle sound, but not the engine driving sound.
And the references are correctly assigned. I can't find the solution... Someone have a idea ?
P.S : I'm doing the tutorial on Unity 5.3.5
For more details : The Tanks Tutorial
Answer by gryphox1 · Jun 02, 2017 at 03:15 AM
It doesn't work for me either.
Looks like that particular asset in the tutorial just wasn't uploaded properly, from their end. You can just use the EngineIdle audioclip there as well or search for/make another audioclip.
I thought I might find something $$anonymous$$e also like that and didn't work either
and this post have been 4 yrs not answered :(
Your answer
Follow this Question
Related Questions
Audio Source does not contain definition for any of the Play functions... 2 Answers
Soundarray for player is not working properly 1 Answer
Simple question on how to use multiple FMOD sounds on one object. 0 Answers
Stop AudioSource on Trigger!!! 1 Answer
How to play a random audio clip from an array in C#? 3 Answers