Esempio n. 1
0
    /// <summary>
    /// removes all cars then recreates them
    /// </summary>
    private void createCars()
    {
        //delete all of the cars then create new ones
        if (carList != null)
        {
            for (int i = 0; i < carList.Count; i++)
            {
                Destroy(carList[i].gameObject);
            }
        }

        carList = new List <carNetwork>();
        //creates/recreates the cars
        for (int i = 0; i < populationSize; i++)
        {
            //create the car then asign it a neural network
            carNetwork car = ((GameObject)Instantiate(carPrefab, startingPos.transform.position, startingPos.transform.rotation)).GetComponent <carNetwork>();
            car.Init(neuralNetworkList[i]);
            carList.Add(car);
        }
    }
Esempio n. 2
0
 // Update is called once per frame
 void Update()
 {
     if (!created)
     {
         created = true;
         createNetwork();
         car = ((GameObject)Instantiate(carPrefab, transform.position, transform.rotation)).GetComponent <carNetwork>();
         car.Init(champNetwork);
     }
     if (car.lapGateTime < 10)
     {
         car.lapGateTime = 10000000;
     }
     if (Input.GetKeyDown(KeyCode.Space))
     {
         farCamera.enabled    = !farCamera.enabled;
         followCamera.enabled = !followCamera.enabled;
     }
     followCamera.transform.rotation = iniRot;
     followCamera.transform.position = car.transform.position + new Vector3(0, 10, 0);
 }