void Start() { if (brakeLights == null) { brakeLights = GetComponent <BrakeLights>(); } if (drivetrain == null) { drivetrain = GetComponent <Drivetrain>(); } if (aerodynamicResistance == null) { aerodynamicResistance = GetComponent <AerodynamicResistance>(); } if (soundController == null) { soundController = GetComponent <SoundController>(); } if (carDynamics == null) { carDynamics = GetComponent <CarDynamics>(); } if (axles == null) { axles = GetComponent <Axles>(); } if (axisCarController == null) { axisCarController = GetComponent <AxisCarController>(); } if (carDamage == null) { carDamage = GetComponent <CarDamage>(); } if (arcader == null) { arcader = GetComponent <Arcader>(); } if (setup == null) { setup = GetComponent <Setup>(); } if (bodyRb == null) { bodyRb = GetComponent <Rigidbody>(); } if (camerasController == null) { camerasController = GetComponent <CamerasController>(); } }
void SetComponent(){ drivetrain = GetComponent<Drivetrain>(); cardynamics = GetComponent<CarDynamics>(); forceFeedback= GetComponent<ForceFeedback>(); physicMaterials =GetComponent<PhysicMaterials>(); arcader= GetComponent<Arcader>(); aerodynamicResistance= GetComponent<AerodynamicResistance>(); axles= GetComponent<Axles>(); axisCarController = GetComponent <AxisCarController>(); mouseCarController = GetComponent <MouseCarController>(); mobileCarController = GetComponent <MobileCarController>(); fuelTanks=GetComponentsInChildren<FuelTank>(); wings=GetComponentsInChildren<Wing>(); }
public IEnumerator ChangeCar(GameObject mselectedCar){ if(mselectedCar!=null){ mTransform=mselectedCar.transform; mrigidbody = mselectedCar.GetComponent<Rigidbody>(); carDynamics = mselectedCar.GetComponent<CarDynamics>(); drivetrain = mselectedCar.GetComponent<Drivetrain>(); aerodynamicResistance = mselectedCar.GetComponent<AerodynamicResistance>(); carDebug = mTransform.GetComponent<CarDebug>(); carDamage = mselectedCar.GetComponent<CarDamage>(); carController = mselectedCar.GetComponent<CarDynamics>().carController; dashBoard=mselectedCar.transform.GetComponentInChildren<DashBoard>(); arcader=mselectedCar.transform.GetComponentInChildren<Arcader>(); setup= mselectedCar.GetComponent<Setup>(); axles=mselectedCar.GetComponent<Axles>(); fuelTanks=mselectedCar.GetComponentsInChildren<FuelTank>(); currentFuels=new float[fuelTanks.Length]; if (setup!=null && setup.enabled==true) {while (setup.loadingSetup==true) yield return new WaitForSeconds(0.02f);} if (drivetrain.engineTorqueFromFile==true) drivetrain.CalcValues(factor,drivetrain.engineTorqueFromFile); drivetrain.engineTorqueFromFile=false; if (Application.isEditor && setup!=null && setup.enabled==true){ GridEntrys = new string[] {"Engine", "Transmission", "Suspensions", "Brakes" ,"Tires", "Body", "Assistance","Save Setup"}; entrysCount=8; } else{ GridEntrys = new string[] {"Engine", "Transmission", "Suspensions", "Brakes" ,"Tires", "Body", "Assistance"}; entrysCount=7; } if (arcader) arcader.enabled=false; m_maxTorque=drivetrain.maxTorque; //ESP=carController.ESP; selectedCar=mselectedCar; //carDynamics.SetTiresType(); tiresTypeFront=(int)axles.frontAxle.tires; tiresTypeRear=(int)axles.rearAxle.tires; //drivetrain.SetTransmission(drivetrain.transmission); transmissionType=oldTransmissionType=(int)drivetrain.transmission; //SetCOGPosition(carDynamics.zlocalPosition); boundingSize=carDynamics.BoundingSize(selectedCar.GetComponentsInChildren<Collider>()); zlocalPositionLimit=0.8f*boundingSize.x/4.5f; engageRPM=drivetrain.engageRPM; maxRPM=(Mathf.CeilToInt(drivetrain.maxRPM/1000)+1)*1000; maxKmh=Mathf.RoundToInt(maxRPM*axles.frontAxle.leftWheel.radius*2*0.1885f/(drivetrain.gearRatios[drivetrain.gearRatios.Length-1]*drivetrain.finalDriveRatio)); // Mathf.PI*3.6f/60 -> 0.1885 mass=mrigidbody.mass; StartSize = new Vector2(Screen.width, Screen.height); if (grid!=null) floor=(grid.height - gridHeight)/2; top=gridHeight+Mathf.RoundToInt(gridHeight*0.17f)+floor; RectCalculation(StartSize); ScrollRectCalculation(StartSize, drivetrain.gearRatios.Length-2); factor=1; if (grid!=null){ switch(GridInt) { case 0: ApplyEngineTorque();break; case 1: ApplyGears();break; } } } }
// Initialize void Start() { if (centerOfMass != null) rigidbody.centerOfMass = centerOfMass.localPosition; rigidbody.inertiaTensor *= inertiaFactor; drivetrain = GetComponent (typeof (Drivetrain)) as Drivetrain; ar = GetComponent(typeof(AerodynamicResistance)) as AerodynamicResistance; }