// Initialization section // --------------------------------------------------------------------------------------------- // Default values when the component is first instanced. // These will be overriden when serialized values are available. Perrinn424CarController() { frontAxle = new VPAxle(); rearAxle = new VPAxle(); frontAxle.steeringMode = Steering.SteeringMode.Steerable; frontAxle.brakeCircuit = Brakes.BrakeCircuit.Front; rearAxle.brakeCircuit = Brakes.BrakeCircuit.Rear; }
void ConfigureAxle(VPAxle axle, int leftWheelIndex, int rightWheelIndex, TireFrictionBase tireFriction) { WheelState leftWheelState = wheelState[leftWheelIndex]; WheelState rightWheelState = wheelState[rightWheelIndex]; Wheel leftWheelBlock = wheels[leftWheelIndex]; Wheel rightWheelBlock = wheels[rightWheelIndex]; bool isSteeringAxle = axle.steeringMode != Steering.SteeringMode.Disabled; // Configure the mandatory data per wheel ConfigureWheelData(leftWheelState, leftWheelBlock, axle.leftWheel, tireFriction, isSteeringAxle); ConfigureWheelData(rightWheelState, rightWheelBlock, axle.rightWheel, tireFriction, isSteeringAxle); // Configure steering if (isSteeringAxle) { m_steering.AddWheel(leftWheelState, GetWheelLocalPosition(axle.leftWheel), axle.steeringMode, axle.steeringRatio); m_steering.AddWheel(rightWheelState, GetWheelLocalPosition(axle.rightWheel), axle.steeringMode, axle.steeringRatio); } }
// Compute the longitudinal position of an axle (local) float GetAxleLocalPosition(VPAxle axle) { return(0.5f * (GetWheelLocalPosition(axle.leftWheel).z + GetWheelLocalPosition(axle.rightWheel).z)); }