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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Error: Music speed affected by camera movement

Discussion in 'Audio & Video' started by Thorles, Mar 31, 2015.

  1. Thorles

    Thorles

    Joined:
    Mar 31, 2015
    Posts:
    4
    Please help me because this drives me nuts.
    I am trying to make a first person game where the player flies in the space. The camera is controlled by mouse, and the player flies automatically where the camera points.

    This is the script for the camera movement:

    var flySpeed = 1;
    var defaultCam : GameObject;
    var playerObject : GameObject;
    function Update()
    {
    if (Time.timeScale>0)
    transform.Translate(Vector3.forward * flySpeed);
    }

    When I comment the translate part, the music plays perfectly, my camera stays, where it was when i started the game, and it can only look around.
    When i uncomment this part, the camera flies, but the music plays faster or slower. It depends on, where i look with the camera.
    The component for the music and the main camera has nothing to do with each other (so neither of them is children of the another)
     
  2. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    279
    That's probably because of the AudioSource's Doppler Level. If you go to the 3D settings of the the AudioSource you can change it.
     
  3. Thorles

    Thorles

    Joined:
    Mar 31, 2015
    Posts:
    4
    Yeah literally 5 minutes after i posted this, i jokingly pulled the doppler level down (Because of Sheldon Coopers Halloween Costume from Season 1) then my jaw dropped when i realized that the problem was gone. I wrote to a moderator to delete this post, but anyway thank you for your reply!