Audiosource change pitch through code?

Hello, so for the crash detector sound we did it as code using PlayOneShot. My question is if we wanted to change the pitch or volume or anything else like we did with the first one just inserting it into the audiosource compononent how would that be done? Obvioulsy this isn’t all that important especially for this as I just moved it to the audosource after doing it through code so I could change the pitch. Wondering if there was a way to change the pitch within code in case we had multiple audio clips we wanted on our player. Thanks in advance!

AudioSource audioSource = GetComponent<AudioSource>();
audioSource.pitch = Random.Range(0.9f, 1.1f);
audioSource.Play(); // Or playoneshot
1 Like

Thanks!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms