Пример #1
0
    void AddTruckBehaviour(GameObject car)
    {
        Dot_Truck_Controller CarController = car.AddComponent <Dot_Truck_Controller>();
        vehicle veh = car.GetComponent <vehicle>();

        car.AddComponent <Rigidbody>().mass = veh.mass;

        //CarController.maxMotorTorque = 1500;
        //CarController.maxMotorTorque = veh.horse_power + veh.maxrotmomentum;

        CarController.maxSteeringAngle    = 45;
        CarController.maxRPM              = veh.tach_with_max_power * 2.5f; // veh.tach_with_max_power * 2.5f от фонаря написал
        CarController.breakpower          = veh.breakpower;
        CarController.maxrotmomentum      = veh.maxrotmomentum;
        CarController.horse_power         = veh.horse_power;
        CarController.gearsCount          = veh.gearCount1;
        CarController.rear_axle_coeff     = veh.rear_axle_coeff;
        CarController.reverse_trans_coeff = veh.reverse_trans_coeff;
        CarController.gear_trans_coeff1   = veh.gear_trans_coeff[1];
        CarController.gear_trans_coeff2   = veh.gear_trans_coeff[2];
        CarController.gear_trans_coeff3   = veh.gear_trans_coeff[3];
        CarController.gear_trans_coeff4   = veh.gear_trans_coeff[4];
        CarController.gear_trans_coeff5   = veh.gear_trans_coeff[5];
        CarController.gear_trans_coeff6   = veh.gear_trans_coeff[6];
        CarController.gear_trans_coeff7   = veh.gear_trans_coeff[7];
        CarController.gear_trans_coeff8   = veh.gear_trans_coeff[8];
        CarController.gear_trans_coeff9   = veh.gear_trans_coeff[9];
        CarController.gear_trans_coeff10  = veh.gear_trans_coeff[10];
        CarController.gear_trans_coeff11  = veh.gear_trans_coeff[11];
        CarController.gear_trans_coeff12  = veh.gear_trans_coeff[12];
        CarController.gear_trans_coeff13  = veh.gear_trans_coeff[13];

        //CKS ColKeyState = gob.Find("hit_"+veh.CarNode);
        //GameObject ColKeyState = gob.Find(CollisionKey).gameObject;
        //ColKeyState.aaa = "1";
        int wheelCount = veh.WheelMe.Count / 2;

        CarController.truck_Infos = new List <Dot_Truck>();


        for (int j = 0; j < wheelCount; j++)
        {
            Dot_Truck dt = new Dot_Truck();
            dt.leftWheelMesh = veh.WheelMe[j * 2].transform.GetChild(0).gameObject;

            dt.rightWheelMesh = veh.WheelMe[j * 2 + 1].transform.GetChild(0).gameObject;
            CarController.truck_Infos.Add(dt);
            if (j == 0)
            {
                dt.steering = true;
            }
            else
            {
                dt.motor = true;
            }
        }
    }
    public void VisualizeWheel(Dot_Truck wheelPair)
    {
        Quaternion rot;
        Vector3    pos;

        wheelPair.leftWheel.GetWorldPose(out pos, out rot);
        wheelPair.leftWheelMesh.transform.position = pos;
        wheelPair.leftWheelMesh.transform.rotation = rot;
        wheelPair.rightWheel.GetWorldPose(out pos, out rot);
        wheelPair.rightWheelMesh.transform.position = pos;
        wheelPair.rightWheelMesh.transform.rotation = rot;
    }
Пример #3
0
    public void enableCarToMove(int engineNo)
    {
        print(engineNo);
        canMove = true;

        maxSpeed = maxSpeed * engineNo;
        foreach (Wheel truck_Info in wheelInfo)
        {
            Dot_Truck dc = new Dot_Truck();
            dc.wheel     = truck_Info.wheel;
            dc.wheelMesh = truck_Info.wheelMesh;
            dc.steering  = truck_Info.steering;
            dc.motor     = truck_Info.motor;

            GetComponent <Dot_Truck_Controller> ().truck_Infos.Add(dc);
        }
        GetComponent <Dot_Truck_Controller> ().wheelInfo = wheelInfo;

        //GetComponent<Dot_Truck_Controller> ().maxMotorTorque = maxSpeed * engineNo;
    }