Skip to content

Commit

Permalink
increased brake torque and added it as a serialized field (#17)
Browse files Browse the repository at this point in the history
* increased brake torque and added it as a serialized field

* Removed comments and spaces

* serialized field fix

brakeTorque value is now initialized in the editor instead of awake()

* Replaced instance of Math.abs with Mathf.abs and removed unnecessary using statement
  • Loading branch information
AyushKulk authored Feb 9, 2024
1 parent ae70df2 commit 5fe3d2e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Assets/Scenes/Simulator.unity
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
_noise: 0
_reportPeriod: 0.05
initGPS:
- 0
- 0
initLat: 0
initLon: 0
--- !u!1 &144878289
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -876,6 +875,7 @@ MonoBehaviour:
_statusReportPeriod: 0.033333335
_torqueMultiplier: 4
_display: {fileID: 513085395}
brakeTorque: 10000
--- !u!1 &1069975640
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1374,6 +1374,7 @@ MonoBehaviour:
_statusReportPeriod: 0.033333335
_torqueMultiplier: 4
_display: {fileID: 726416728}
brakeTorque: 10000
--- !u!1 &1365518634
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1460,6 +1461,7 @@ MonoBehaviour:
_statusReportPeriod: 0.033333335
_torqueMultiplier: 4
_display: {fileID: 2126870834}
brakeTorque: 10000
--- !u!1 &1416975727
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2523,6 +2525,7 @@ MonoBehaviour:
_statusReportPeriod: 0.033333335
_torqueMultiplier: 4
_display: {fileID: 5025346310533158112}
brakeTorque: 10000
--- !u!1 &919132148984513418
GameObject:
m_ObjectHideFlags: 0
Expand Down
8 changes: 8 additions & 0 deletions Assets/Scripts/WheelMotor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class WheelMotor : Motor

private WheelCollider _wheel;

[SerializeField]
private float brakeTorque;

protected override void Awake()
{
base.Awake();
Expand All @@ -25,6 +28,11 @@ private void FixedUpdate()
UpdatePower();
UpdatePosition();
Render();
if (Mathf.Abs(CurrentPower) <= 0.05) {
_wheel.brakeTorque = brakeTorque;
} else {
_wheel.brakeTorque = 0f;
}
_wheel.motorTorque = CurrentPower * _torqueMultiplier;
}

Expand Down

0 comments on commit 5fe3d2e

Please sign in to comment.