mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-27 06:20:17 +00:00
extract function
This commit is contained in:
parent
f6fe21cbdb
commit
b0ec6417c7
1 changed files with 14 additions and 9 deletions
|
@ -486,15 +486,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
||||||
|
|
||||||
wheel.Child.transform.localPosition = position;
|
wheel.Child.transform.localPosition = position;
|
||||||
|
|
||||||
// reset the yaw
|
UpdateWheelRotation(wheel, wheel.Collider.rpm, wheel.Collider.steerAngle);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_colorsChanged)
|
if (_colorsChanged)
|
||||||
|
@ -516,6 +508,19 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
||||||
PhysicsFixedUpdate();
|
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()
|
void UpdateHighDetailMeshes()
|
||||||
{
|
{
|
||||||
this.HighDetailMeshesParent.SetPositionAndRotation(this.transform.position, this.transform.rotation);
|
this.HighDetailMeshesParent.SetPositionAndRotation(this.transform.position, this.transform.rotation);
|
||||||
|
|
Loading…
Reference in a new issue