Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved Pitch not changing when setting it by script

Discussion in 'Audio & Video' started by Zarod, Dec 21, 2023.

  1. Zarod

    Zarod

    Joined:
    Jan 20, 2016
    Posts:
    67
    I can change it in the editor, but the script doesn't seem to work

    i am just setting the pitch equals to a float.

    :(
     
  2. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    438
    Are you sure you have the right AudioSource reference? Also it's worth noting that the range of pitch is -3 to 3.
     
  3. Zarod

    Zarod

    Joined:
    Jan 20, 2016
    Posts:
    67
    Now it works :/

    i'm going to re-examine my code before resolving this bug .... because it could be that the audiosource prevents pitch changes if the operation is invalid ... i'm going to check right now
     
  4. Zarod

    Zarod

    Joined:
    Jan 20, 2016
    Posts:
    67
    For the life of me, i cannot reproduce it anymore ... even the past versions of the same script now work xD

    for reference I was already aware of how unity handles stuff in the editor and in build, thus i tried getting the audio source in both methods, direct reference and GetComponent()

    now everything works as it should

    EDIT: i " DID " restart the editor tho ... that might have been the cause of the problem
     
    SeventhString likes this.