protected override void InitOtherThings() { base.InitOtherThings(); // 获取引用 LoadPart(ref _engine); LoadParts(ref _wheels); List <VCPVehicleWheel> steerWheelsList = new List <VCPVehicleWheel>(_wheels.Length); List <VCPVehicleWheel> motorWheelsList = new List <VCPVehicleWheel>(_wheels.Length); foreach (var wheel in _wheels) { if (wheel.isSteerWheel) { steerWheelsList.Add(wheel); } if (wheel.isMotorWheel) { motorWheelsList.Add(wheel); } } //_steerWheels = steerWheelsList.ToArray(); _motorWheels = motorWheelsList.ToArray(); // 轮胎边界框 Vector3 lp = _wheels[0].transform.localPosition; float maxZ = lp.z; float minZ = lp.z; float maxX = lp.x; float minX = lp.x; foreach (var wheel in _wheels) { lp = wheel.transform.localPosition; if (lp.z > maxZ) { maxZ = lp.z; } if (lp.z < minZ) { minZ = lp.z; } if (lp.x > maxX) { maxX = lp.x; } if (lp.x < minX) { minX = lp.x; } } _wheelRangeWidth = maxX - minX; // 初始化轮胎转角 float angle = PEVCConfig.instance.maxWheelSteerAngle; foreach (var wheel in _wheels) { Vector3 loc = wheel.transform.localPosition; float steerZ = (maxZ - minZ < 0.1f) ? 1f : ((loc.z - (maxZ + minZ) * 0.5f) / ((maxZ - minZ) * 0.5f)); float radius = Interpolation.EaseOut(Mathf.Clamp01(_wheelRangeWidth * 0.125f)) * PEVCConfig.instance.vehicleSteerRadiusExtend + PEVCConfig.instance.vehicleSteerRadiusBase; float steerXL = angle + Mathf.Asin((maxX - loc.x) * Mathf.Sin(angle) / radius); float steerXR = angle + Mathf.Asin((loc.x - minX) * Mathf.Sin(angle) / radius); wheel.Init(this, steerXL * steerZ, steerXR * steerZ); } }
public static float GetArmorDefence(float durability) { float d01 = Mathf.Clamp01(durability / PEVCConfig.instance.maxArmorDurability); return(Interpolation.EaseOut(d01) * PEVCConfig.instance.maxArmorDefence); }