void Awake()
    {
        //Debug.Log("Hey");
        car             = this.gameObject;
        carAIController = car.GetComponent <CarAIControl>();
        carController   = car.GetComponent <CarController>();

        agent = car.GetComponentInChildren <NavMeshAgent>();
        agent.transform.localPosition = new Vector3();
        agent.transform.rotation      = new Quaternion();

        if (destination == null)
        {
            destination = car.transform;
        }

        /*agent.SetDestination(destination.position);
         * zebraCrossPathMask = 1 << NavMesh.GetAreaFromName("ZebraCross");
         */

        if (carController.m_SpeedType == SpeedType.KPH)
        {
            agent.speed = carController.m_Topspeed * 0.447f;
        }
        else if (carController.m_SpeedType == SpeedType.MPH)
        {
            agent.speed = carController.m_Topspeed * 0.278f;
        }
    }
Ejemplo n.º 2
0
 private void OnTriggerEnter(Collider other)
 {
     progresstracker = car.GetComponent <WaypointProgressTracker>();
     carControl      = car.GetComponent <CarAIControl>();
     //progresstracker.gameObject.SetActive(false);
     //carControl.gameObject.SetActive(false);
     car.AddComponent <CirclingMotion>();
 }
Ejemplo n.º 3
0
    void spawnCar(int id, gene brain)
    {
        CarAIControl car = Instantiate(carPrefab, transform.position, Quaternion.identity);

        car.cpm     = this.cpm;
        car.brain   = brain;
        car.trainer = this;
        car.id      = id;
    }
Ejemplo n.º 4
0
    //GameObject cube;

    private void Start()
    {
        carAIControl    = GetComponent <CarAIControl>();
        currentWaypoint = 0;
        // cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
        // cube.name = "Cube";
        // cube.transform.localScale = new Vector3(2,2, 2);
        // DestroyImmediate(cube.GetComponent<BoxCollider>());
    }
Ejemplo n.º 5
0
 void Start()
 {
     car              = GetComponent <CarController>();
     car_state        = GetComponent <csCarState>();
     ai               = GetComponent <CarAIControl>();
     tracker          = GetComponent <WaypointProgressTracker>();
     Original_Destroy = GameObject.Find("Original_Target_Setting").GetComponent <csDestroy_Original>();
     Ranking          = GameObject.Find("Directional Light").GetComponent <csRanking>();
     GameTimer        = GameObject.Find("Directional Light").GetComponent <csGameTimer>();
 }
Ejemplo n.º 6
0
 private void Start()
 {
     winningCanvas.gameObject.SetActive(false);
     losingCanvas.gameObject.SetActive(false);
     FinishCollider       = FinishingLine.GetComponent <BoxCollider>();
     gameWon              = false;
     game_over            = false;
     winningCarController = winningCar.gameObject.GetComponent <CarController>();
     AIcontroller         = winningCar.gameObject.GetComponent <CarAIControl>();
 }
Ejemplo n.º 7
0
    void Start()
    {
        my_ai      = GetComponent <CarAIControl>();
        my_control = GetComponent <CarUserControl>();
        my_pause   = GetComponent <pause_controller_s>();
        my_wpt     = GetComponent <WaypointProgressTracker>();

        Update_Lap_Display();
        SetComponents();
    }
Ejemplo n.º 8
0
    void OnTriggerExit(Collider col)
    {
        //if (state == carsState.STOP) {
        CarAIControl carAI = col.gameObject.GetComponent <CarAIControl> ();

        if (carAI != null)
        {
            carAI.run = true;
        }
        //}
    }
Ejemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        user = GetComponent <CarUserControl>();
        ai   = GetComponent <CarAIControl>();
        ai.SetTarget(GameObject.Find("AI_Target").transform);

        control = GetComponent <CarController>();

        user.enabled = false;
        ai.enabled   = true;
    }
Ejemplo n.º 10
0
 void Start()
 {
     ai               = GetComponent <CarAIControl>();
     CollCheck        = GetComponent <csCollisionCheck>();
     car              = GetComponent <CarController>();
     childBody        = gameObject.transform.FindChild("Image").gameObject;
     car_body         = gameObject.transform.FindChild("Body").gameObject;
     Big_Jump_Target  = GameObject.Find("Big_Jump_Area").transform.FindChild("Big_Jump_Point");
     Big_Jump_Target1 = GameObject.Find("Big_Jump_Area").transform.FindChild("Big_Jump_Point1");
     tracker          = GetComponent <WaypointProgressTracker>();
     StartCoroutine(JumperTrigger());
 }
Ejemplo n.º 11
0
    // Use this for initialization
    void Start()
    {
        carAI         = GetComponent <CarAIControl>();
        carController = GetComponent <CarController>();
        if (chaseTarget == null)
        {
            chaseTarget = GameObject.FindGameObjectWithTag("DeliveryTruck");
        }

        emptyTransformPrefab = (GameObject)Instantiate(emptyTransformPrefab, chaseTarget.transform.position, chaseTarget.transform.rotation);
        path = new NavMeshPath();

        needPath     = true;
        pointCounter = 0;
        stallTimer   = timeToWait;
    }
 // Start is called before the first frame update
 void Start()
 {
     NumberOfWrongGuesses  = 0;
     WaypointCarController = WaypointCar.gameObject.GetComponent <CarController>();
     WaypointCarAudio      = WaypointCar.gameObject.GetComponent <CarAudio>();
     aicontrol             = WaypointCar.gameObject.GetComponent <CarAIControl>();
     StarterCanvas.gameObject.SetActive(true);
     WaypointCarController.m_Topspeed = 80;
     camera.gameObject.transform.SetParent(StarterCanvas.transform);
     //Somehow make WaypointCarAudio inaudible
     WaypointCar.gameObject.SetActive(false);
     ProceedButton.onClick.AddListener(EnableGame);
     Incorrect.gameObject.SetActive(false);
     CodeExecPanel.gameObject.SetActive(false);
     soundPlayed = false;
     PauseCanvas.gameObject.SetActive(false);
 }
Ejemplo n.º 13
0
 // Use this for initialization
 void Start()
 {
     Debug.Log(isTraining);
     topSpeed  = carController.MaxSpeed;
     recording = false;
     RecordingPause.SetActive(false);
     RecordStatus_Text.text = "RECORD";
     DriveStatus_Text.text  = "";
     SaveStatus_Text.text   = "";
     SetAngleValue(0);
     SetMPHValue(0);
     carAI = car.GetComponent <CarAIControl>();
     if (!isTraining)
     {
         DriveStatus_Text.text = "Mode: Autonomous";
         RecordDisabled.SetActive(true);
         RecordStatus_Text.text = "";
     }
 }
    // setup script properties
    private void Start()
    {
        _carAIControl = GetComponent <CarAIControl>();
        // we use a transform to represent the point to aim for, and the point which
        // is considered for upcoming changes-of-speed. This allows this component
        // to communicate this information to the AI without requiring further dependencies.

        // You can manually create a transform and assign it to this component *and* the AI,
        // then this component will update it, and the AI can read it.
        if (target == null)
        {
            target = new GameObject(name + " Waypoint Target").transform;
        }
        circuit = FindObjectOfType <WaypointCircuit>();
        if (circuit != null)
        {
            circuitFound = true;
        }
        Reset();
    }
Ejemplo n.º 15
0
 private void OnCollisionStay(Collision col)
 {
     if (col.rigidbody != null)
     {
         CarAIControl component = col.rigidbody.GetComponent <CarAIControl>();
         if (component != null)
         {
             this.avoidOtherCarTime = Time.time + 1f;
             if (Vector3.Angle(base.transform.forward, component.transform.position - base.transform.position) < 90f)
             {
                 this.avoidOtherCarSlowdown = 0.5f;
             }
             else
             {
                 this.avoidOtherCarSlowdown = 1f;
             }
             Vector3 vector = base.transform.InverseTransformPoint(component.transform.position);
             float   f      = Mathf.Atan2(vector.x, vector.z);
             this.avoidPathOffset = this.lateralWanderDistance * -Mathf.Sign(f);
         }
     }
 }
Ejemplo n.º 16
0
    void SetTarget()
    {
        camera.SetTarget(cars[currentCarIndex].transform);
        CarController newCar = cars[currentCarIndex];

        CarAIControl   aiControl   = newCar.GetComponent <CarAIControl>();
        CarUserControl userControl = newCar.GetComponent <CarUserControl>();

        if (aiControl)
        {
            aiControl.enabled = false;
        }

        if (userControl)
        {
            userControl.enabled = true;
        }

        if (currentCar)
        {
            aiControl   = currentCar.GetComponent <CarAIControl>();
            userControl = currentCar.GetComponent <CarUserControl>();

            if (aiControl)
            {
                aiControl.enabled = true;
            }

            if (userControl)
            {
                userControl.enabled = false;
            }
        }

        currentCar = newCar;
    }
Ejemplo n.º 17
0
 void Start()
 {
     obj = GameObject.Find("Car").GetComponent <CarController>();
     aa  = GameObject.Find("Car").GetComponent <CarAIControl>();
 }
Ejemplo n.º 18
0
 void Start()
 {
     carm   = this.GetComponent <Camera>();
     car_AI = GameObject.FindGameObjectWithTag("Player").GetComponent <CarAIControl>();
 }
Ejemplo n.º 19
0
 void Start()
 {
     ai = GetComponent<CarAIControl>();
     CollCheck = GetComponent<csCollisionCheck>();
     car = GetComponent<CarController>();
     childBody = gameObject.transform.FindChild("Image").gameObject;
     car_body = gameObject.transform.FindChild("Body").gameObject;
     Big_Jump_Target = GameObject.Find("Big_Jump_Area").transform.FindChild("Big_Jump_Point");
     Big_Jump_Target1 = GameObject.Find("Big_Jump_Area").transform.FindChild("Big_Jump_Point1");
     tracker = GetComponent<WaypointProgressTracker>();
     StartCoroutine(JumperTrigger());
 }
 private void Start()
 {
     ai = GetComponent <CarAIControl>();
 }
Ejemplo n.º 21
0
 void Start()
 {
     car = GetComponent<CarController>();
     car_state = GetComponent<csCarState>();
     ai = GetComponent<CarAIControl>();
     tracker = GetComponent<WaypointProgressTracker>();
     Original_Destroy = GameObject.Find("Original_Target_Setting").GetComponent<csDestroy_Original>();
     Ranking = GameObject.Find("Directional Light").GetComponent<csRanking>();
     GameTimer = GameObject.Find("Directional Light").GetComponent<csGameTimer>();
 }
Ejemplo n.º 22
0
        // ------------------------------------------------- //

        private void Awake()
        {
            carAI           = GetComponent <CarAIControl>();
            carController   = GetComponent <CarController>();
            waypointTracker = GetComponent <WaypointProgressTracker>();
        }
Ejemplo n.º 23
0
 void Start()
 {
     obj = GameObject.Find("Car").GetComponent<CarController>();
     aa = GameObject.Find("Car").GetComponent<CarAIControl>();
 }
Ejemplo n.º 24
0
 private void OnTriggerEnter(Collider other)
 {
     carAI = car.GetComponent <CarAIControl>();
     carAI.m_CautiousSpeedFactor = number;
 }