I have written a script where i enable(active) the CarController script attach to the Car. I have taken car from UnityStandardAssets.
Initially CarController script component will be unactive as i dont want the car to move on certain occations.
Below is script to set the car in motion.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CarControlActive : MonoBehaviour
{
public GameObject CarControl;
void Start()
{
CarControl.GetComponent<UnityStandardAssets.Vehicles.Car.CarController>().enabled = true;
}
}
I have attched the above script to an empty gameobject(CarControlActive).
But, when i set the CarController script component unactive i get the following error on my console.