Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Multiple Vehicle Audiosources

$
0
0
Hello i am having some problem with play specific audio sources, For some reason i cannot get them to play, I have tried a number of different things but just can't crack it, public AudioSource tankEngine; public AudioSource tankTracks; public AudioSource tankIdle; void Start(){ AudioSource[] audios = GetComponents(); tankEngine = audios[0]; tankTracks = audios[1]; tankIdle = audios[2]; } void OnGUI(){ if(CurrentSpeed > 0) tankEngine.pitch = 0.5f + (CurrentSpeed / maxSpeed); tankEngine.Play(); } Everything else works like a charm but except it will not play, If i remove "tankEngine.Play();" from the script then just enable Play On Awake on the GO Prefab's AudioSource then it will work fine with the pitch acceleration etc. I have been trying to get it to play from script so i can then stop the audio once stationary to play a idle audio clip. Any ideas? Thanks.

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>