public void createCars(int carNum, int carID, int mode) { this.carNum = carNum; this.carID = carID; carControl = new carController[carNum]; Vector3 position; for (int i = 0; i < carNum; i++) { position = startPosition + new Vector3(8 * i, 0, 0); GameObject obj; if (mode == SINGLEPLAYER) //multiMode.SINGLEPLAYER){ { obj = Instantiate(CarP0, position, Quaternion.identity) as GameObject; if (i == carID) { carControl[i] = obj.GetComponent <playerCar>(); carControl[i].setCarID(i); carControl[i].setCarNum(carNum); carControl[i].started = true; Debug.Log("in"); } } else { if (i == carID) { obj = Instantiate(getCarType(c.getCarTypes(i), true), position, Quaternion.identity) as GameObject; carControl[i] = obj.GetComponent <playerCar>(); } else { obj = Instantiate(getCarType(c.getCarTypes(i), false), position, Quaternion.identity) as GameObject; carControl[i] = obj.GetComponent <internetCar>(); } carControl[i].setCarID(i); carControl[i].setCarNum(carNum); } } }