Inheritance: UnityEngine.MonoBehaviour
Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        car_variant = GameObject.FindGameObjectWithTag("Player");
        text        = GameObject.Find("LapTimeText");
        s_text      = GameObject.Find("SpeedText");
        finish      = GameObject.Find("FinalText");

        car_body = car_variant.GetComponent <Rigidbody>();

        finish.SetActive(false);

        lap_time_text = text.GetComponent <Text>();
        speed_text    = s_text.GetComponent <Text>();

        check_point_check = car_variant.GetComponent <CheckpointCheck>();
        car_controller    = car_variant.GetComponent <UnityStandardAssets.Vehicles.Car.CarController>();
        car_user_control  = car_variant.GetComponent <UnityStandardAssets.Vehicles.Car.CarUserControl>();

        current_speed   = car_controller.CurrentSpeed;
        speed_text.text = current_speed.ToString();

        lap_time           = check_point_check.lap_time;
        lap_time_text.text = "LAP TIME: ";

        victory = check_point_check.victory;
    }
Exemplo n.º 2
0
 private void Awake()
 {
     timer     = -flipTimeout;
     ciManager = gameObject.GetComponent <CarInteractionManager> ();
     m_Car     = GetComponent <UnityStandardAssets.Vehicles.Car.CarController>();
     id        = gameObject.name;
 }
Exemplo n.º 3
0
        private void Awake()
        {
            // get the car controller
            m_Car = GetComponent<CarController>();


        }
Exemplo n.º 4
0
 void Start()
 {
     controller      = GetComponent <UnityStandardAssets.Vehicles.Car.CarController> ();
     aiController    = GetComponent <UnityStandardAssets.Vehicles.Car.CarAIControl> ();
     progressTracker = GetComponent <UnityStandardAssets.Utility.WaypointProgressTracker> ();
     sceneManager    = GameObject.Find("Race Scene Manager").GetComponent <RG_SceneManager>();
 }
Exemplo n.º 5
0
        private void Awake()
        {
            // get the car controller
            m_Car = GetComponent<CarController>();

            if (coolDownJump == null)
                coolDownJump = 2;
        }
Exemplo n.º 6
0
        private void Awake()
        {
            // get the car controller reference
            m_CarController = GetComponent<CarController>();

            // give the random perlin a random value
            m_RandomPerlin = Random.value*100;

            m_Rigidbody = GetComponent<Rigidbody>();
        }
Exemplo n.º 7
0
    // Use this for initialization
    protected override void Start()
    {
        base.Start();

        m_asAudio = GetComponent <AudioSource>();
        m_fCurrentBerzerkValue = 0f;
        m_ccCarController      = GetComponent <UnityStandardAssets.Vehicles.Car.CarController>();
        IsDead             = false;
        m_bShieldActivated = false;
    }
Exemplo n.º 8
0
    private void Awake()
    {
        m_Car = GetComponent <UnityStandardAssets.Vehicles.Car.CarController>();

        weightsList = new List <double[][, ]>();

        carColl = transform.GetChild(0).GetChild(0).gameObject.GetComponent <CarCollisionChecker>();

        defPos = transform.position;
        defRot = transform.rotation;
    }
Exemplo n.º 9
0
 void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
     }
     else if (_instance != this)
     {
         Destroy(gameObject);
     }
     carController = GetComponents <UnityStandardAssets.Vehicles.Car.CarController> ()[0];
     rigidBody     = GetComponent <Rigidbody> ();
 }
Exemplo n.º 10
0
 // Update is called once per frame
 void Update()
 {
     if (!didIt)
     {
         if (Vector3.Distance(myTransform.position, target.position) < range)
         {
             didIt = true;
             Debug.Log("Switching car modes");
             controller = car.GetComponent<UnityStandardAssets.Vehicles.Car.CarController>();
             GetComponent<AudioSource>().PlayOneShot(Leviosa);
             controller.switchMode();
         }
     }
 }
Exemplo n.º 11
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         UnityStandardAssets.Vehicles.Car.CarController pi = other.GetComponentInParent <UnityStandardAssets.Vehicles.Car.CarController>();
         pi.pacForm      = true;
         pi.pac_duration = 500;
         Destroy(this.gameObject);
     }
     if (other.gameObject.tag == "Pacman")
     {
         Destroy(this.gameObject);
     }
 }
Exemplo n.º 12
0
 //On hit Boost
 void OnTriggerEnter(Collider other)
 {
     //Boost player
     if (other.gameObject.tag == "Player")
     {
         UnityStandardAssets.Vehicles.Car.CarController pi = other.GetComponentInParent <UnityStandardAssets.Vehicles.Car.CarController>();
         pi.boosted        = true;
         pi.boost_duration = 500;
         Destroy(this.gameObject);
     }
     //Kill power up
     if (other.gameObject.tag == "Pacman")
     {
         Destroy(this.gameObject);
     }
 }
Exemplo n.º 13
0
        void Init()
        {
            _Car = GetComponent<CarController>();

            if (_Player)
            {
                CarUserControl.Instance.m_Car = _Car;
                CarGUI.Instance._Car = _Car;
                CarUserControl.Instance._CameraTarget = transform.SearchChildWithTag("Target");
                CarUserControl.Instance.SetCamera();
                SpawnPlayers.Instance._PlayerSpawned = true;
            }
            _HitBoxParent = transform.SearchChildWithTag("HitBoxsParent");
            _HitBoxs = _HitBoxParent.GetComponentsInChildren<HitBox>();
            Counting();
            _isAlive = true;
        }
Exemplo n.º 14
0
        private CarController m_CarController; // Reference to car we are controlling


        private void StartSound()
        {
            // get the carcontroller ( this will not be null as we have require component)
            m_CarController = GetComponent<CarController>();

            // setup the simple audio source
            m_HighAccel = SetUpEngineAudioSource(highAccelClip);

            // if we have four channel audio setup the four audio sources
            if (engineSoundStyle == EngineAudioOptions.FourChannel)
            {
                m_LowAccel = SetUpEngineAudioSource(lowAccelClip);
                m_LowDecel = SetUpEngineAudioSource(lowDecelClip);
                m_HighDecel = SetUpEngineAudioSource(highDecelClip);
            }

            // flag that we have started the sounds playing
            m_StartedSound = true;
        }
        // Use this for initialization
        void Start()
        {
            waypointlist[0] = new Vector3(-20.6f, 0f, 126.2f);
            waypointlist[1] = new Vector3(35.6f, 0f, 138.8f);
            waypointlist[2] = new Vector3(78.7f, 0f, 105.3f);
            waypointlist[3] = new Vector3(98.4f, 0f, 43.9f);
            waypointlist[4] = new Vector3(75.8f , 0f, -13.3f);
            waypointlist[5] = new Vector3(28.4f, 0f, -18.4f);
            waypointlist[6] = new Vector3(-4.2f, 0f, -2.3f);
            waypointlist[7] = new Vector3(-18.7f, 0f, 26f);
            waypointlist[8] = new Vector3(-31.6f, 0f, 57.4f);
            waypointlist[9] = new Vector3(-30f, 0f, 95f);
            carai = GetComponent(typeof(CarAIControl)) as CarAIControl;
            car = carai.GetComponent(typeof(CarController)) as CarController;
            waypointholder.position = waypointlist[0];
            carai.SetTarget(waypointholder);
            for (int i = 0; i < 10; i++)
            {
                GameObject.Instantiate(marker);
                marker.transform.position = waypointlist[i];
            }
            lasttime = 0;

            //In start initialize both
            currentCameraIndex = 0;
            //Turn all cameras off, except the first default one
            for (int i=1; i<cameras.Length; i++)
            {
                cameras[i].gameObject.SetActive(false);
            }

            //If any cameras were added to the controller, enable the first one
            if (cameras.Length>0)
            {
                cameras [0].gameObject.SetActive (true);
            }
        }
Exemplo n.º 16
0
 private void Awake()
 {
     // get the car controller
     m_Car  = GetComponent <CarController>();
     source = this.GetComponent <AudioSource>();
 }
Exemplo n.º 17
0
        private CarController m_Car; // the car controller we want to use


        private void Awake()
        {
            // get the car controller
            m_Car = GetComponent <CarController>();
        }
Exemplo n.º 18
0
 // Start is called before the first frame update
 void Start()
 {
     carScript = Car.GetComponent <UnityStandardAssets.Vehicles.Car.CarController>();
 }
Exemplo n.º 19
0
 void Start()
 {
     cac = GetComponent <UnityStandardAssets.Vehicles.Car.CarAIControl> ();
     cc  = GetComponent <UnityStandardAssets.Vehicles.Car.CarController> ();
 }
Exemplo n.º 20
0
 private void Start()
 {
     m_Car          = GetComponent <CarController>();
     _netMqListener = new NetMqListener(HandleMessageCar);
     _netMqListener.Start();
 }
Exemplo n.º 21
0
 private void Awake()
 {
     // get the car controller
     m_Car = GetComponent<CarController>();
     source = this.GetComponent<AudioSource>();
 }
Exemplo n.º 22
0
 private void Awake()
 {
     _car = GetComponent<CarController>();
 }
Exemplo n.º 23
0
        //public Text input;


        private void Awake()
        {
            // get the car controller
            m_Car = GetComponent<CarController>();
            //previousAngle = target.transform.rotation.eulerAngles.z;
        }
Exemplo n.º 24
0
 private CarController m_Car; // the car controller we want to use
 // Use this for initialization
 void Start()
 {
     m_Car = GetComponent <CarController>();
 }
Exemplo n.º 25
0
 // Use this for initialization
 void Start()
 {
     dial  = GetComponent <TextMesh> ();
     timer = 0f;
     cc    = car.GetComponent <UnityStandardAssets.Vehicles.Car.CarController> ();
 }
Exemplo n.º 26
0
 private void Reset()
 {
     m_Rigidbody   = this.GetComponent <Rigidbody>();
     carController = this.GetComponent <UnityStandardAssets.Vehicles.Car.CarController>();
 }
Exemplo n.º 27
0
 // Start is called before the first frame update
 void Start()
 {
     controller = car.transform.GetComponent <UnityStandardAssets.Vehicles.Car.CarController>();
     thisSpeedo = this;
 }
Exemplo n.º 28
0
        public void Start()
        {
            cc = GetComponent <CarController>();
//			cc.TestTorque();
        }
Exemplo n.º 29
0
 private void Awake()
 {
     // get the car controller
     m_Car   = GetComponent <CarController>();
     arduino = GetComponent <ArduinoConnectorScriptCar>();
 }
Exemplo n.º 30
0
    /*
     * Manages one race.
     */

    //Sets up all the references the racemanager will need. Car is set from the gamemanager script.
    public void setUpReferences()
    {
        m_CarOnTriggerEnter = m_Car.GetComponentInChildren <CarOnTriggerEnter> ();
        m_CarController     = m_Car.GetComponentInChildren <UnityStandardAssets.Vehicles.Car.CarController> ();
    }
Exemplo n.º 31
0
 private void Awake()
 {
     m_Car = GetComponent <CarController>();
 }
Exemplo n.º 32
0
    private void Update()
    {
        int startFrame = 10;
        int offset     = 0;

        if (num > startFrame)
        {
            int    num1           = num - startFrame + offset;
            string imageName      = num1.ToString().PadLeft(6, '0') + ".jpg";
            string depthMapName   = num1.ToString().PadLeft(6, '0') + ".jpg";
            string pointCloudName = num1.ToString().PadLeft(6, '0') + ".bin";

            if (speedupCapture)
            {
                //only transfer mode for once in one frame, either from rgb to depth or from depth to rgb, to reduce computation
                if (isImageMode)
                {
                    //RGB image capture
                    if (captureImage)
                    {
                        //changeShader(rgbShader);
                        byte[] image = getRenderResult();
                        File.WriteAllBytes(outputPath + "//images//" + imageName, image);
                    }

                    if (captureDepthMap || capturePointCloud)
                    {
                        changeShader(depthShader);
                        isImageMode = false;

                        //depth map capture
                        if (captureDepthMap)
                        {
                            byte[] imageDepth = getRenderResult();
                            File.WriteAllBytes(outputPath + "//depth//" + depthMapName, imageDepth);
                        }

                        //point cloud capture
                        if (capturePointCloud)
                        {
                            byte[] pcByteArray = getPointCloud();
                            File.WriteAllBytes(outputPath + "//velodyne//" + pointCloudName, pcByteArray);
                        }
                    }
                }
                else
                {
                    if (captureDepthMap || capturePointCloud)
                    {
                        //depth map capture
                        if (captureDepthMap)
                        {
                            byte[] imageDepth = getRenderResult();
                            File.WriteAllBytes(outputPath + "//depth//" + depthMapName, imageDepth);
                        }

                        //point cloud capture
                        if (capturePointCloud)
                        {
                            byte[] pcByteArray = getPointCloud();
                            File.WriteAllBytes(outputPath + "//velodyne//" + pointCloudName, pcByteArray);
                        }
                    }

                    //RGB image capture
                    if (captureImage)
                    {
                        changeShader(rgbShader);
                        isImageMode = true;
                        byte[] image = getRenderResult();
                        File.WriteAllBytes(outputPath + "//images//" + imageName, image);
                    }
                }
            }
            else
            {
                //always change the shader back to rgb.

                //RGB image capture
                if (captureImage)
                {
                    //changeShader(rgbShader);
                    //isImageMode = true;
                    byte[] image = getRenderResult();
                    File.WriteAllBytes(outputPath + "//images//" + imageName, image);
                }

                if (captureDepthMap || capturePointCloud)
                {
                    changeShader(depthShader);
                    isImageMode = false;

                    //depth map capture
                    if (captureDepthMap)
                    {
                        byte[] imageDepth = getRenderResult();
                        File.WriteAllBytes(outputPath + "//depth//" + depthMapName, imageDepth);
                    }

                    //point cloud capture
                    if (capturePointCloud)
                    {
                        byte[] pcByteArray = getPointCloud();
                        File.WriteAllBytes(outputPath + "//velodyne//" + pointCloudName, pcByteArray);
                    }
                }

                if (!isImageMode)
                {
                    changeShader(rgbShader);
                    isImageMode = true;
                }
            }

            // Copy calibration data
            if (copyCameraCalibration)
            {
                string sourceFile = outputPath + "//calib//base.txt";
                string destFile   = outputPath + "//calib//" + num1.ToString().PadLeft(6, '0') + ".txt";
                System.IO.File.Copy(sourceFile, destFile, true);
            }

            if (saveEnd2EndLabel)
            {
                string fileName = outputPath + "//end2endLabels.csv";
                UnityStandardAssets.Vehicles.Car.CarController carController =
                    GameObject.Find("MainCar").GetComponent <UnityStandardAssets.Vehicles.Car.CarController>();
                WriteTrainData(fileName, imageName, carController.CurrentSteerAngle);
            }

            if (saveBoundingBoxLabel)
            {
                String       contents = getBoundingBox2D(cars, "Car") + getBoundingBox2D(vans, "Van") + getBoundingBox2D(trams, "Tram");
                string       fileName = outputPath + "//labels//" + num1.ToString().PadLeft(6, '0') + ".txt";
                StreamWriter writer   = new StreamWriter(fileName);
                writer.WriteLine(contents);
                writer.Close();
            }

            //changeShader(rgbShader);
            RenderTexture.active  = null;
            mainCam.targetTexture = null;
        }

        num++;
    }
Exemplo n.º 33
0
 // Start is called before the first frame update
 void Start()
 {
     rb            = GetComponent <Rigidbody>();
     carController = GetComponent <UnityStandardAssets.Vehicles.Car.CarController>();
     Monitor.SetActive(true);
 }
 public void Start()
 {
     cc = GetComponent<CarController>();
     //			cc.TestTorque();
 }
		private void Awake()
		{
			// Set up the reference to the aeroplane controller.
			m_Aeroplane = GetComponent<CarController>();
		}
Exemplo n.º 36
0
 void Awake()
 {
     carController = GetComponent<UnityStandardAssets.Vehicles.Car.CarController>();
     playerMgr = GameObject.FindObjectOfType<PlayerManager>();
 }
Exemplo n.º 37
0
 void Awake()
 {
     m_Car = GetComponent <UnityStandardAssets.Vehicles.Car.CarController>();
 }
Exemplo n.º 38
0
        private void Start()
        {
            Time.timeScale = 1;
            maxVelocity    = 20;
            acceleration   = 1f;

            timeStep      = 0.05f;
            numberOfSteps = 5;
            time          = 0;

            steerDirection        = 0;
            accelerationDirection = 0;
            brake            = 0;
            handBrake        = 0;
            crashed          = false;
            crashTime        = 0;
            crashCheckTime   = 0.5f;
            crashDirection   = 0;
            previousPosition = Vector3.up;

            terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>();
            m_Car           = GetComponent <CarController>();

            InitializeCSpace();


            // note that both arrays will have holes when objects are destroyed
            // but for initial planning they should work
            friends = GameObject.FindGameObjectsWithTag("Player");
            enemies = GameObject.FindGameObjectsWithTag("Enemy");
            MSC     = GameObject.FindGameObjectWithTag("CreateMSC");
            int carNumber = 0;

            for (int i = 0; i < friends.Length; ++i)
            {
                if (friends[i].name == this.name)
                {
                    carNumber = i;
                    break;
                }
            }

            Debug.Log("Start computing path");

            List <Vector3>[] all_paths = MSC.GetComponent <CreateMSC>().GetPaths();
            List <Vector3>   my_path   = all_paths[carNumber];

            Point startPoint = new Point((int)transform.position.x, (int)transform.position.z);
            Point endPoint   = new Point((int)my_path[0].x, (int)my_path[0].z);

            PathGenerator aStar = new PathGenerator(terrain_manager, null);

            List <Vector3> startPath = aStar.GetPath(startPoint, endPoint, transform.rotation.eulerAngles.y);

            finalPath = startPath;
            mscPath   = new List <Vector3>();

            // Add your own path, without last node (origin)
            for (int i = 0; i < my_path.Count - 2; ++i)
            {
                Point a = new Point((int)my_path[i].x, (int)my_path[i].z);
                Point b = new Point((int)my_path[(i + 1) % my_path.Count].x, (int)my_path[(i + 1) % my_path.Count].z);

                List <Vector3> p;
                float          dir = Quaternion.LookRotation(new Vector3(b.x, 0, b.y) - new Vector3(a.x, 0, a.y)).eulerAngles.y;
                p = aStar.GetPath(a, b, dir);

                mscPath.AddRange(p);
            }

            // Add path of car with final node to yours, so that you can try to complete it
            int     choosen_car      = -1;
            float   dist_closest_end = float.MaxValue;
            Vector3 my_last_node     = my_path[my_path.Count - 2];

            for (int i = 0; i < friends.Length; i++)
            {
                if (i == carNumber)
                {
                    continue;
                }
                if (all_paths[i].Count < 2)
                {
                    continue;
                }
                Vector3 other_car_last_node_path = all_paths[i][all_paths[i].Count - 2];
                float   dist = Vector3.Distance(my_last_node, other_car_last_node_path);
                if (dist < dist_closest_end)
                {
                    dist_closest_end = dist;
                    choosen_car      = i;
                }
            }
            Debug.Log(string.Format("I am {0}, best car: {1}, dist={2}", carNumber, choosen_car, dist_closest_end));
            List <Vector3> other_car_path = all_paths[choosen_car];

            for (int i = other_car_path.Count - 2; i > 0; i--)
            {
                Point a = new Point((int)other_car_path[i].x, (int)other_car_path[i].z);
                Point b = new Point((int)other_car_path[(i - 1) % other_car_path.Count].x, (int)other_car_path[(i - 1) % other_car_path.Count].z);

                List <Vector3> p;
                float          dir = Quaternion.LookRotation(new Vector3(b.x, 0, b.y) - new Vector3(a.x, 0, a.y)).eulerAngles.y;
                p = aStar.GetPath(a, b, dir);

                mscPath.AddRange(p);
            }
            Debug.Log("Path computed");
        }
 // Use this for initialization
 void Start()
 {
     car       = GetComponent <UnityStandardAssets.Vehicles.Car.CarController>();
     initSpeed = car.m_Topspeed;
 }
        public float CrossTrackError(CarController cc)
        {
            next_wp = NextWaypoint(cc);
            var pos = cc.transform.position;

            // Previous waypoint
            prev_wp = next_wp - 1;
            if (next_wp == 0)
            {
                prev_wp = waypoints.Count - 1;
            }

            // This projects the vehicle position onto the line
            // from the previous waypoint to the next waypoint.
            var n = waypoints[next_wp] - waypoints[prev_wp];
            var x = pos - waypoints[prev_wp];
            var v = new Vector2(n.x, n.z);

            // current vehicle position
            var x0 = new Vector2(x.x, x.z);

            // find the projection of x onto v
            var proj = (Vector2.Dot(x0, v) / Mathf.Abs(v.x * v.x + v.y * v.y)) * v;

            var t = Mathf.Clamp(proj.magnitude / n.magnitude, 0, 1);
            // Debug.Log(string.Format("Progress between waypoints {0} and {1} = {2}", prev_wp, next_wp, t));
            // Cross track error
            // var threshold = 0.05f;
            // if (t >= (1 - threshold)) {
            //     var p0 = prev_wp;
            //  var p1 = next_wp;
            //  var p2 = (next_wp + 1) % waypoints.Count;
            //  var i1 = threshold * waypoints[p0] + (1-threshold) * waypoints[p1];
            //  var i2 = (1-threshold) * waypoints[p1] + threshold * waypoints[p2];
            //  var v0 = new Vector2(i1.x, i1.z);
            //  var v1 = new Vector2(waypoints[p1].x, waypoints[p1].z);
            //  var v2 = new Vector2(i2.x, i2.z);
            //     var newt = (t - (1-threshold)) /  (threshold * 2f);
            //  var bp = BezierPoint(v0, v1, v2, newt) - new Vector2(waypoints[p0].x, waypoints[p0].z);
            //  // Debug.Log(string.Format("Bezier point {0}, Actual projection {1}, Position {2} {3} {4}", bp, proj, x0, t, newt));
            //  proj = bp;
            // } else if (t <= threshold) {
            //     var p2 = next_wp;
            //     var p1 = prev_wp;
            //  var p0 = prev_wp - 1;
            //  if (p1 == 0) {
            //      p0 = waypoints.Count-1;
            //  }
            //  var i1 = threshold * waypoints[p0] + (1-threshold) * waypoints[p1];
            //  var i2 = (1-threshold) * waypoints[p1] + threshold * waypoints[p2];
            //  var v0 = new Vector2(i1.x, i1.z);
            //  var v1 = new Vector2(waypoints[p1].x, waypoints[p1].z);
            //  var v2 = new Vector2(i2.x, i2.z);
            //     var newt = (t / (threshold * 2f)) + 0.5f;
            //  var bp = BezierPoint(v0, v1, v2, newt) - new Vector2(waypoints[p1].x, waypoints[p1].z);
            //  // Debug.Log(string.Format("Bezier point {0}, Actual projection {1}, Position {2} {3} {4}", bp, proj, x0, t, newt));
            //  proj = bp;
            // }

            var cte = (x0 - proj).magnitude;
            // Debug.Log(string.Format("pos = {0}, v = {1} proj = {2}, cte = {3}", x0, v, proj, cte));


            // This compares the projected position and the current vehicle position
            // to a point in the center of the lake.
            // If projected position is closer is means the vehicle is to the right of the line
            // hence the CTE will be negative (turn left).
            // If the vehicle position is closer is means the vehicle is to the left of the line
            // hence the CTE will be positive (turn right).
            var centerPoint   = new Vector3(-14.4f, 0f, 76.9f) - waypoints[prev_wp];
            var centerPoint2D = new Vector2(centerPoint.x, centerPoint.z);
            var centerToPos   = Vector2.Distance(centerPoint2D, x0);
            var centerToRef   = Vector2.Distance(centerPoint2D, proj);

            if (centerToPos <= centerToRef)
            {
                cte *= -1f;
            }
            return(cte);
        }
Exemplo n.º 41
0
 private void Awake()
 {
     // get the car controller
     m_Car = GetComponent <UnityStandardAssets.Vehicles.Car.CarController>();
 }
Exemplo n.º 42
0
        public string playerControllerID = "P1"; // player id string to be added to end of input name to change it to the proper player input

        public void Initialize()
        {
            // get the car controller
            m_Car = GetComponent <CarController>();
        }
Exemplo n.º 43
0
 protected override void initialize()
 {
     car  = GetComponent<CarController>();
     item = GetComponent<MyCarItem>();
 }
Exemplo n.º 44
0
 private void Awake()
 {
     // get the car controller
     m_Car = GetComponent <CarController>();
     rb    = this.GetComponent <Rigidbody>();
 }