Search Unity

UnassignedReferenceException error.

Discussion in 'Scripting' started by autobotlongarm, Feb 13, 2019.

  1. autobotlongarm

    autobotlongarm

    Joined:
    Jan 1, 2018
    Posts:
    19
    Hello, so I am using a Racing Game Kit and have ran into a problem. So I keep on getting a error about UnassignedReferenceError and I don't know what to do. When I tested it, the engine sound went to "Audio Souce" while Engine Audio went unused. Also, the shift sound didn't play.
     
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,035
    Unity is telling you where the problem is. Look at the gameobject which has the Car_Controller script attached and you will likely see that it has a field call Gear Shift Audio Source which is not populated. Drag a reference to the AudioSource there and all should be good.
     
  3. autobotlongarm

    autobotlongarm

    Joined:
    Jan 1, 2018
    Posts:
    19
    Is this what it looks like?

    Now, when I create a new vehicle the shift sounds go to the engine audio source.
     
  4. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,035
    No. The name of the variable which is unassigned is gearShiftAudioSource so would appear in the inspector as Gear Shift Audio souce unless you have an editor script which is manually naming the variables in the inspector.
     
    Joe-Censored likes this.
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    If you continue to have issues, either post an image of the entire inspector window for the Car_Controller component (which likely has a field with the variable name that is reporting as null), or contact the creator of the kit you're using.