diff --git a/Assets/Scripts/Behaviours/Vehicles/Vehicle.cs b/Assets/Scripts/Behaviours/Vehicles/Vehicle.cs index e82011fe..a47a9d8f 100644 --- a/Assets/Scripts/Behaviours/Vehicles/Vehicle.cs +++ b/Assets/Scripts/Behaviours/Vehicles/Vehicle.cs @@ -486,15 +486,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles wheel.Child.transform.localPosition = position; - // reset the yaw - wheel.Child.localRotation = wheel.Roll; - - // calculate new roll - wheel.Child.Rotate(wheel.IsLeftHand ? Vector3.left : Vector3.right, wheel.Collider.rpm / 60.0f * 360.0f * Time.deltaTime); - wheel.Roll = wheel.Child.localRotation; - - // apply yaw - wheel.Child.localRotation = Quaternion.AngleAxis(wheel.Collider.steerAngle, Vector3.up) * wheel.Roll; + UpdateWheelRotation(wheel, wheel.Collider.rpm, wheel.Collider.steerAngle); } if (_colorsChanged) @@ -516,6 +508,19 @@ namespace SanAndreasUnity.Behaviours.Vehicles PhysicsFixedUpdate(); } + public static void UpdateWheelRotation(Wheel wheel, float rpm, float steerAngle) + { + // reset the yaw + wheel.Child.localRotation = wheel.Roll; + + // calculate new roll + wheel.Child.Rotate(wheel.IsLeftHand ? Vector3.left : Vector3.right, rpm / 60.0f * 360.0f * Time.deltaTime); + wheel.Roll = wheel.Child.localRotation; + + // apply yaw + wheel.Child.localRotation = Quaternion.AngleAxis(steerAngle, Vector3.up) * wheel.Roll; + } + void UpdateHighDetailMeshes() { this.HighDetailMeshesParent.SetPositionAndRotation(this.transform.position, this.transform.rotation);