Skip to content

Commit

Permalink
Update Wheel.cs
Browse files Browse the repository at this point in the history
Added wheel RPM calculations
  • Loading branch information
samserious25 authored Sep 17, 2019
1 parent 24443a0 commit a5603f5
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Assets/Adrenak/Tork/Physics/Scripts/Wheel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ public class Wheel : MonoBehaviour {
/// The torque the brake is applying on the wheel
/// </summary>
public float brakeTorque { get; set; }


/// <summary>
///Revolutions per minute of the wheel
/// </summary>
public float RPM { get; private set; }

/// <summary>
/// Whether the wheel is touching the ground
/// </summary>
Expand Down Expand Up @@ -167,8 +172,16 @@ void FixedUpdate() {
transform.localEulerAngles = new Vector3(0, steerAngle, 0);
CalculateSuspension();
CalculateFriction();
}

CalculateRPM();
}

void CalculateRPM()
{
float metersPerMinute = rigidbody.velocity.magnitude * 60;
float wheelCircumference = 2 * Mathf.PI * radius;
RPM = metersPerMinute / wheelCircumference;
}

void CalculateSuspension() {
float rayLen = GetRayLen();
m_Ray.direction = -transform.up.normalized;
Expand Down

0 comments on commit a5603f5

Please sign in to comment.