// Token: 0x06000C90 RID: 3216 RVA: 0x000389A4 File Offset: 0x00036BA4 private void ApplyWheelForces(HoverEngine wheel, float gas, bool driveWheel, AnimationCurve slidingWheelTractionCurve) { if (wheel.isGrounded) { float d = 0.005f; Transform transform = wheel.transform; float d2 = 1f; Vector3 position = transform.position; Vector3 pointVelocity = this.rigidbody.GetPointVelocity(position); Vector3 a = Vector3.Project(pointVelocity, transform.right); Vector3 a2 = Vector3.Project(pointVelocity, transform.forward); Vector3 up = Vector3.up; Debug.DrawRay(position, pointVelocity, Color.blue); Vector3 a3 = Vector3.zero; if (driveWheel) { a3 = transform.forward * gas * this.motorForce; this.rigidbody.AddForceAtPosition(transform.forward * gas * this.motorForce * d2, position); Debug.DrawRay(position, a3 * d, Color.yellow); } Vector3 vector = Vector3.ProjectOnPlane(-a2 * this.rollingFrictionCoefficient * d2, up); this.rigidbody.AddForceAtPosition(vector, position); Debug.DrawRay(position, vector * d, Color.red); Vector3 vector2 = Vector3.ProjectOnPlane(-a * slidingWheelTractionCurve.Evaluate(pointVelocity.magnitude) * this.slidingTractionCoefficient * d2, up); this.rigidbody.AddForceAtPosition(vector2, position); Debug.DrawRay(position, vector2 * d, Color.red); Debug.DrawRay(position, (a3 + vector + vector2) * d, Color.green); } }
// Token: 0x06000C92 RID: 3218 RVA: 0x00038B54 File Offset: 0x00036D54 private void UpdateWheelParameter(HoverEngine wheel, HoverVehicleMotor.WheelLateralAxis wheelLateralAxis, HoverVehicleMotor.WheelLongitudinalAxis wheelLongitudinalAxis) { wheel.hoverForce = this.hoverForce; wheel.hoverDamping = this.hoverDamping; wheel.hoverHeight = this.hoverHeight; wheel.offsetVector = this.hoverOffsetVector; wheel.hoverRadius = this.hoverRadius; Vector3 zero = Vector3.zero; zero.y = -this.wheelWellDepth; if (wheelLateralAxis != HoverVehicleMotor.WheelLateralAxis.Left) { if (wheelLateralAxis == HoverVehicleMotor.WheelLateralAxis.Right) { zero.x = this.trackWidth / 2f; } } else { zero.x = -this.trackWidth / 2f; } if (wheelLongitudinalAxis != HoverVehicleMotor.WheelLongitudinalAxis.Front) { if (wheelLongitudinalAxis == HoverVehicleMotor.WheelLongitudinalAxis.Back) { zero.z = -this.wheelBase / 2f; } } else { zero.z = this.wheelBase / 2f; } wheel.transform.localPosition = zero; }
// Token: 0x06000C93 RID: 3219 RVA: 0x00038C24 File Offset: 0x00036E24 private void UpdateAllWheelParameters() { foreach (HoverVehicleMotor.AxleGroup axleGroup in this.staticAxles) { HoverEngine leftWheel = axleGroup.leftWheel; HoverEngine rightWheel = axleGroup.rightWheel; this.UpdateWheelParameter(leftWheel, HoverVehicleMotor.WheelLateralAxis.Left, axleGroup.wheelLongitudinalAxis); this.UpdateWheelParameter(rightWheel, HoverVehicleMotor.WheelLateralAxis.Right, axleGroup.wheelLongitudinalAxis); } foreach (HoverVehicleMotor.AxleGroup axleGroup2 in this.steerAxles) { HoverEngine leftWheel2 = axleGroup2.leftWheel; HoverEngine rightWheel2 = axleGroup2.rightWheel; this.UpdateWheelParameter(leftWheel2, HoverVehicleMotor.WheelLateralAxis.Left, axleGroup2.wheelLongitudinalAxis); this.UpdateWheelParameter(rightWheel2, HoverVehicleMotor.WheelLateralAxis.Right, axleGroup2.wheelLongitudinalAxis); } }
// Token: 0x06000C94 RID: 3220 RVA: 0x00038CCC File Offset: 0x00036ECC private void FixedUpdate() { this.UpdateCenterOfMass(); this.UpdateAllWheelParameters(); if (this.inputBank) { Vector3 moveVector = this.inputBank.moveVector; Vector3 normalized = Vector3.ProjectOnPlane(this.inputBank.aimDirection, base.transform.up).normalized; float num = Mathf.Clamp(Util.AngleSigned(base.transform.forward, normalized, base.transform.up), -this.maxSteerAngle, this.maxSteerAngle); float magnitude = moveVector.magnitude; foreach (HoverVehicleMotor.AxleGroup axleGroup in this.staticAxles) { HoverEngine leftWheel = axleGroup.leftWheel; HoverEngine rightWheel = axleGroup.rightWheel; this.ApplyWheelForces(leftWheel, magnitude, axleGroup.isDriven, axleGroup.slidingTractionCurve); this.ApplyWheelForces(rightWheel, magnitude, axleGroup.isDriven, axleGroup.slidingTractionCurve); } foreach (HoverVehicleMotor.AxleGroup axleGroup2 in this.steerAxles) { HoverEngine leftWheel2 = axleGroup2.leftWheel; HoverEngine rightWheel2 = axleGroup2.rightWheel; float num2 = this.maxTurningRadius / Mathf.Abs(num / this.maxSteerAngle); float num3 = Mathf.Atan(this.wheelBase / (num2 - this.trackWidth / 2f)) * 57.29578f; float num4 = Mathf.Atan(this.wheelBase / (num2 + this.trackWidth / 2f)) * 57.29578f; Quaternion localRotation = Quaternion.Euler(0f, num3 * Mathf.Sign(num), 0f); Quaternion localRotation2 = Quaternion.Euler(0f, num4 * Mathf.Sign(num), 0f); if (num <= 0f) { leftWheel2.transform.localRotation = localRotation; rightWheel2.transform.localRotation = localRotation2; } else { leftWheel2.transform.localRotation = localRotation2; rightWheel2.transform.localRotation = localRotation; } this.ApplyWheelForces(leftWheel2, magnitude, axleGroup2.isDriven, axleGroup2.slidingTractionCurve); this.ApplyWheelForces(rightWheel2, magnitude, axleGroup2.isDriven, axleGroup2.slidingTractionCurve); } Debug.DrawRay(base.transform.position, normalized * 5f, Color.blue); } }