mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-14 16:27:19 +00:00
Extract method
This commit is contained in:
parent
03de3a068d
commit
3e4f8d91a1
1 changed files with 11 additions and 1 deletions
|
@ -179,14 +179,24 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
|||
if (wheel.Complement != null) wheel.UpdateTravel();
|
||||
}
|
||||
|
||||
this.AddAntiRollForceToRigidBody();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds upward force to rigid body based on difference of travel between complemented wheels.
|
||||
/// </summary>
|
||||
void AddAntiRollForceToRigidBody()
|
||||
{
|
||||
foreach (var wheel in _wheels.Where(x => x.Complement != null))
|
||||
{
|
||||
if (wheel.Travel == wheel.Complement.Travel) continue;
|
||||
if (!wheel.Collider.isGrounded) continue;
|
||||
|
||||
var force = (wheel.Complement.Travel - wheel.Travel) * vals.AntiRollScale;
|
||||
var force = (wheel.Complement.Travel - wheel.Travel) * VConsts.Instance.AntiRollScale;
|
||||
_rigidBody.AddForceAtPosition(wheel.Parent.transform.up * force, wheel.Parent.position);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue