Beispiel #1
0
        // Constructor
        public Cars(int nr_of_cars_, GameObject carGameObject)
        {
            Vector3 spawn = new Vector3(CarSpawnPoint.transform.position.x + 0.001f, CarSpawnPoint.transform.position.y, CarSpawnPoint.transform.position.z);

            nr_of_cars = nr_of_cars_;
            CarPrefab  = carGameObject;

            for (int i = 0; i < nr_of_cars; i++)
            {
                spawn = new Vector3(spawn.x - 0.001f, spawn.y, spawn.z);

                GameObject spawnedCar = Instantiate(CarPrefab, spawn, CarSpawnPoint.transform.rotation);
                CarClass   newcar     = new CarClass(spawnedCar, 0.0f, 0.0f);

                CarList.Add(i, newcar);
            }
        }