void Start() { rb = GetComponent <Rigidbody>(); lipo = GetComponent <Lipo>(); if (lipo == null) { lipo = GetComponentInChildren <Lipo>(); } rb.maxAngularVelocity = 35; quadMesh = transform.GetChild(0); startPos = transform.position; startRot = transform.rotation; pidRoll = new PID(); pidPitch = new PID(); pidYaw = new PID(); XDocument thrcur = XDocument.Parse(StaticDataAccess.config.fs.Read(ConfigManager.basePath + "thrcur.xml")); XDocument curthr = XDocument.Parse(StaticDataAccess.config.fs.Read(ConfigManager.basePath + "curthr.xml")); powertrain = new Powertrain(); powertrain.throttleCurrentCurve.Deserialize(thrcur.Element("dataCurve")); powertrain.currentThrustCurve.Deserialize(curthr.Element("dataCurve")); }
public Acceleration() { VehicleModel = new VehicleModel(); PowerTrain = new Powertrain(); }
public override void Accelerate() { Powertrain.Accelerate(); }
public override void ApplyBrakes() { Powertrain.ApplyBrakes(); }
protected override void OnInitialize() { // Prepare the internal helpers: inertia, steering m_inertia = new Inertia(); m_inertia.settings = inertia; m_inertia.Apply(cachedRigidbody); m_steering = new Steering(); m_steering.settings = steering; // Declare the number of wheels SetNumberOfWheels(4); // Verify wheel references if (frontAxle.leftWheel == null || frontAxle.rightWheel == null || rearAxle.leftWheel == null || rearAxle.rightWheel == null) { DebugLogError("Some VPWheelCollider references are missing in the axles.\nAll axles must have a reference to the corresponding left-right VPWheelCollider objects."); enabled = false; return; } // Initialize tire friction if (frontTires == null || rearTires == null) { DebugLogError("Missing tire settings. Ensure both front and rear tires are set"); enabled = false; return; } // We now have the inherited properties wheels[wheelCount] and wheelsState[wheelCount]. // Configure the wheels in the axles accordingly: // // - Mandatory data // - Steering // - Brakes ConfigureAxle(frontAxle, 0, 1, frontTires.GetTireFriction()); ConfigureAxle(rearAxle, 2, 3, rearTires.GetTireFriction()); // Configure an independent powertrain per axle m_frontPowertrain = new Powertrain(wheels[0], wheels[1]); m_frontPowertrain.mgu.settings = frontMgu; m_frontPowertrain.differential.settings = frontDifferential; m_rearPowertrain = new Powertrain(wheels[2], wheels[3]); m_rearPowertrain.mgu.settings = rearMgu; m_rearPowertrain.differential.settings = rearDifferential; // Configure axle sensors m_frontAxleSensor.Configure(this, 0); m_rearAxleSensor.Configure(this, 1); // Initialize internal data m_gearMode = (int)Gearbox.AutomaticGear.N; m_prevGearMode = (int)Gearbox.AutomaticGear.N; data.Set(Channel.Input, InputData.AutomaticGear, m_gearMode); }