Comments state the problem was solved
Car from Unity's standard assets giving me of null reference errors
I imported the unity standard assets vehicles to use the car it provides (In C#). I attached a script that makes it possible to enter the car and a box collider, but the car's audio and controller is spamming me with null reference errors. I haven't done anything to change the scripts that are returning this errors, so I don't understand. In the CarController script, I have noticed that the errors come from a variable called 'm_Rigidbody' that is set in the Start function like this:
// Took away the rest of the code to make it clearer
private Rigidbody m_Rigidbody;
private void Start()
{
m_Rigidbody = GetComponent<Rigidbody>();
}
Here are the errors:
#1 Error
NullReferenceException: Object reference not set to an instance of an object
UnityStandardAssets.Vehicles.Car.CarController.get_CurrentSpeed () (at Assets/Standard Assets/Vehicles/Car/Scripts/CarController.cs:53)
UnityStandardAssets.Vehicles.Car.CarController.ApplyDrive (Single accel, Single footbrake) (at Assets/Standard Assets/Vehicles/Car/Scripts/CarController.cs:224)
UnityStandardAssets.Vehicles.Car.CarController.Move (Single steering, Single accel, Single footbrake, Single handbrake) (at Assets/Standard Assets/Vehicles/Car/Scripts/CarController.cs:153)
UnityStandardAssets.Vehicles.Car.CarUserControl.FixedUpdate () (at Assets/Standard Assets/Vehicles/Car/Scripts/CarUserControl.cs:27)
#2 Error
NullReferenceException: Object reference not set to an instance of an object
UnityStandardAssets.Vehicles.Car.CarController.SteerHelper () (at Assets/Standard Assets/Vehicles/Car/Scripts/CarController.cs:252)
UnityStandardAssets.Vehicles.Car.CarController.Move (Single steering, Single accel, Single footbrake, Single handbrake) (at Assets/Standard Assets/Vehicles/Car/Scripts/CarController.cs:152)
UnityStandardAssets.Vehicles.Car.CarUserControl.FixedUpdate () (at Assets/Standard Assets/Vehicles/Car/Scripts/CarUserControl.cs:27)
#3 Error
NullReferenceException: Object reference not set to an instance of an object
UnityStandardAssets.Vehicles.Car.CarAudio.Update () (at Assets/Standard Assets/Vehicles/Car/Scripts/CarAudio.cs:90)
Reimport the asset. Some prefab from asset have missing script reference
Set the Rigidbody component reference to the m_Rigidbody in the Awake method. That will resolve the error. Since Awake method is called whether GameObject is active/inactive.