//----------------------------------------------------------------------------------------------
        void EnableVehicle(VehicleController vehicle)
        {
            if (vehicle == null) return;

            SetupVehicleComponents(vehicle, true);

            if (cameraController != null)
            {
            VehicleViewConfig viewConfig = vehicle.GetComponent<VehicleViewConfig>();

            if (viewConfig != null)
                {
                // Get the view configuration of the new vehicle and configure the controller

                cameraController.target =
                    viewConfig.lookAtPoint != null? viewConfig.lookAtPoint : vehicle.transform;

                cameraController.targetFixedPosition = viewConfig.driverView;

                cameraController.smoothFollowSettings.distance = viewConfig.viewDistance;
                cameraController.smoothFollowSettings.height = viewConfig.viewHeight;
                cameraController.smoothFollowSettings.rotationDamping = viewConfig.viewDamping;

                cameraController.orbitSettings.distance = viewConfig.viewDistance;
                cameraController.orbitSettings.minDistance = viewConfig.viewMinDistance;
                cameraController.orbitSettings.minVerticalAngle = viewConfig.viewMinHeight;
                }
            else
                {
                cameraController.target = vehicle.transform;
                }

            cameraController.ResetCamera();
            }
        }
        void SetupVehicleComponents(VehicleController vehicle, bool enabled)
        {
            VehicleTelemetry vehicleTelemetry = vehicle.GetComponent<VehicleTelemetry>();
            VehicleStandardInput vehicleInput = vehicle.GetComponent<VehicleStandardInput>();
            VehicleDamage vehicleDamage = vehicle.GetComponent<VehicleDamage>();

            if (vehicleInput != null)
            {
            if (m_commonInput != null)
                {
                if (overrideVehicleComponents)
                    {
                    vehicleInput.enabled = false;
                    m_commonInput.enabled = true;
                    m_commonInput.target = enabled? vehicle : null;
                    }
                else
                    {
                    vehicleInput.enabled = enabled;
                    m_commonInput.enabled = false;
                    }
                }
            else
                {
                vehicleInput.enabled = enabled;
                }
            }
            else
            {
            if (m_commonInput != null)
                {
                m_commonInput.enabled = true;
                m_commonInput.target = enabled? vehicle : null;
                }
            }

            if (vehicleTelemetry != null)
            {
            if (m_commonTelemetry != null)
                {
                if (overrideVehicleComponents)
                    {
                    vehicleTelemetry.enabled = false;
                    m_commonTelemetry.enabled = true;
                    m_commonTelemetry.target = enabled? vehicle : null;
                    }
                else
                    {
                    vehicleTelemetry.enabled = enabled;
                    m_commonTelemetry.enabled = false;
                    }
                }
            else
                {
                vehicleTelemetry.enabled = enabled;
                }
            }
            else
            {
            if (m_commonTelemetry != null)
                {
                m_commonTelemetry.enabled = true;
                m_commonTelemetry.target = enabled? vehicle : null;
                }
            }

            if (vehicleDamage != null)
            {
            vehicleDamage.enableRepairKey = enabled;
            }
        }