Esempio n. 1
0
        void calculateBearing()
        {
            CarAI otherCarAI = carHit.GetComponent <CarAI>();

            ourDis = ownPath.Count - targetIndex;                                      //-(0.1f*temp);//Vector3.Distance(transform.position,goal_pos);
            float otherDis = otherCarAI.ownPath.Count - otherCarAI.targetIndex;        //-(0.1f*otherCarAI.temp);//Vector3.Distance(carHit.transform.position,otherCarAI.goal_pos);

            if (Aggressiveness < otherCarAI.Aggressiveness && !pathsCross(otherCarAI)) //ourDis>otherDis
            {
                temp++;
                waitTimer = 50;
                Vector3 vel = m_Car.GetComponent <Rigidbody>().velocity;
                if (transform.InverseTransformDirection(vel).z > 0.01)
                {
                    newSpeed  = -1;
                    handBrake = 1;
                }
                else if (transform.InverseTransformDirection(vel).z < -0.01)
                {
                    newSpeed  = 1;
                    handBrake = 1;
                }
                else
                {
                    newSpeed  = 0;
                    handBrake = 1;
                }
                m_Car.Move(0, newSpeed, newSpeed, handBrake);
            }

            else
            {
                followPath();
            }
        }
Esempio n. 2
0
        private void Start()
        {
            isGameNight = PersistentModel.Instance.GameNight;

            m_Renderer = GetComponent <Renderer>();

            rearRightlight = gameObject.transform.GetComponent <Light>();
            rearLeftlight  = gameObject.transform.GetComponent <Light>();

            lightMaterial = car.GetComponent <Vehicle>().lightMaterial;
        }
    void Start()
    {
        GameObject path = GameObject.Find("Path").gameObject;

        road = path.GetComponent <Vertices>();

        transform.position = road.trackedPoints[0];
        Vector3 direction = road.trackedPoints[1] - road.trackedPoints[0];

        transform.rotation = Quaternion.LookRotation(direction);

        trafficLights = GameObject.FindGameObjectsWithTag("TrafficLight")
                        .Select(gameObject => gameObject.GetComponent <TrafficLightBehavior>())
                        .ToList();

        rigid = m_Car.GetComponent <Rigidbody>();
    }
Esempio n. 4
0
        float Braking(float newSteer)
        {
            Vector3 vel = m_Car.GetComponent <Rigidbody>().velocity;

            handBrake = 1;
            if (transform.InverseTransformDirection(vel).z > 0.01)
            {
                newSpeed = -1;
            }
            else if (transform.InverseTransformDirection(vel).z < -0.01)
            {
                newSpeed = 1;
            }
            else
            {
                newSpeed = 0;
            }
            m_Car.Move(newSteer, newSpeed, newSpeed, handBrake);
            return(transform.InverseTransformDirection(vel).z);
        }
 void Awake()
 {
     rb = unityCar.GetComponent <Rigidbody>();
     SavePosRot();
 }
Esempio n. 6
0
        //Apply Constant Force
        void UpdateSteeringWheelRotation(float steer)
        {
            //steeringWheel.transform.localRotation = Quaternion.Euler (0, 0, -Input.GetAxis ("Horizontal")*90);
            //if (Input.GetKeyDown (KeyCode.F12))
            //debugGUI = !debugGUI;
            float steer_copy = steer;
            int   force      = (int)Mathf.Round(Mathf.Abs(steer_copy) * Mathf.Sign(steer_copy) * m_Car.GetComponent <Rigidbody>().velocity.magnitude * 7);

            //Debug.Log(force);
            //Debug.Log(force);


            if (force > 0)
            {
                LogitechGSDK.LogiPlayConstantForce(0, force);
            }
            else if (force < 0)
            {
                LogitechGSDK.LogiPlayConstantForce(0, force);
            }
            else
            {
                if (LogitechGSDK.LogiIsPlaying(0, LogitechGSDK.LOGI_FORCE_CONSTANT))
                {
                    LogitechGSDK.LogiStopConstantForce(0);
                }
            }
        }
Esempio n. 7
0
 // Use this for initialization
 void Start()
 {
     carController.GetComponent <CarController>();
 }
 private void Start()
 {
     m_Renderer = GetComponent <Renderer>();
     carA       = GameObject.Find("Car");
     to         = car.GetComponent <TransformObject>();
 }