// WheelState and Wheel objects must be initialized with a minimum data per wheel void ConfigureWheelData(WheelState ws, Wheel wheel, VPWheelCollider wheelCol, TireFrictionBase tireFriction, bool steerable = false) { ws.wheelCol = wheelCol; ws.steerable = steerable; wheel.tireFriction = tireFriction; wheel.radius = wheelCol.radius; wheel.mass = wheelCol.mass; }
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); } }