using UnityEngine; [System.Serializable] public class WheelConfig { public WheelCollider frontLeft; public WheelCollider frontRight; public WheelCollider rearLeft; public WheelCollider rearRight; public WheelCollider[] AllWheels => new[] {frontLeft, frontRight, rearLeft, rearLeft}; public void AdjustToGameObjects(Transform frontWheel, Transform rearWheel, float offset) { var x0 = Vector3.one - Vector3.right; var posFront = frontWheel.localPosition; var newXLeftFront = posFront.x - offset; var newXRightFront = posFront.x + offset; var posRear = rearWheel.localPosition; var newXLeftRear = posRear.x - offset; var newXRightRear = posRear.x + offset; SetNewX(frontLeft.transform, newXLeftFront); SetNewX(frontRight.transform, newXRightFront); SetNewX(rearLeft.transform, newXLeftRear); SetNewX(rearRight.transform, newXRightRear); } private void SetNewX(Transform transform, float newX) { var position = transform.localPosition; position = new Vector3(newX, position.y, position.z); transform.localPosition = position; } }