Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to use AudioSource::pitch in 5?

Discussion in 'Unity 5 Pre-order Beta' started by Lypheus, Oct 31, 2014.

  1. Lypheus


    Apr 16, 2010
    I have the following code which works fine for 4.x:

    Code (csharp):
    2.                // play a sound for this block blowing up in increasing urgency
    3.                 Camera.main.GetComponent<AudioSource>().pitch = Mathf.Clamp( 0.6f + Busts * 0.1f, 0.6f, 1.0f );
    4.                 Camera.main.GetComponent<AudioSource>().PlayOneShot( explosionSound );
    In 5 it still plays the sound but the pitch does not go up with each "bust" in my game - does this mean we need to use AudioMixers in 5 to increase a pitch or is there a new way to accomplish pitch changes in 5?