void Awake()
    {
        string loadeditem = ReadJson.LoadJsonAsResource("DataForSettings/VehicleData/cars");

        Debug.Log(loadeditem);
        oneCar = JsonUtility.FromJson <CarTemplate>(loadeditem);
    }
    // Update is called once per frame
    void Update()
    {
        /*
         * string loadeditem = ReadJson.LoadJsonAsResource("DataForSettings/VehicleData/cars_realtime_updates");
         */
        request             = WebRequest.Create(url);
        request.ContentType = "application/json; charset=utf-8";
        response            = request.GetResponse();
        Stream dataStream = response.GetResponseStream();

        reader = new StreamReader(dataStream);
        string loadeditem = reader.ReadToEnd();



        // string loadeditem = www.text;
        Debug.Log("loaded item:" + loadeditem);
        CarData = JsonUtility.FromJson <CarTemplate>(loadeditem);
        Vector3 movement = CarData.movement;

        transform.rotation = Quaternion.LookRotation(movement);
        transform.position = CarData.position;
        reader.Close();
        response.Close();
    }
Example #3
0
        public CarModel(CarTemplate template)
        {
            CarTransform = template.InstantiateCar();

            _rigidbody = CarTransform.GetComponentInChildren <Rigidbody>();

            _weightComponents = CarTransform.GetComponentsInChildren <IWeightComponent>();

            _motionModel = new MotionModel(CarTransform, template);
        }
        public MotionModel(Transform car, CarTemplate model)
        {
            _model       = model ?? throw new System.NullReferenceException("[CarController] CarTemplate is null");
            _modelIsNull = false;

            _transform = car;

            _rigidbody = _transform.GetComponentInChildren <Rigidbody>();

            _carcase = _transform.GetComponentInChildren <CarCarcase>();

            _engine = _transform.GetComponentInChildren <CarEngine>();

            _fuelTank = _transform.GetComponentInChildren <CarFuelTank>();

            _wheels = _transform.GetComponentsInChildren <CarWheel>();

            InitializeStandartAssetVariables();
        }