major rework
This commit is contained in:
30
Car simulation/Core/Components/BrakeSystem.cs
Normal file
30
Car simulation/Core/Components/BrakeSystem.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Car_simulation.Core.Physics;
|
||||
|
||||
namespace Car_simulation.Core.Components
|
||||
{
|
||||
public class BrakeSystem : ICarComponent
|
||||
{
|
||||
public float BrakeInput { get; set; } = 0f;
|
||||
public float MaxBrakeTorque { get; set; } = 3000f;
|
||||
|
||||
private WheelSystem _wheelSystem;
|
||||
|
||||
public BrakeSystem(WheelSystem wheelSystem)
|
||||
{
|
||||
_wheelSystem = wheelSystem;
|
||||
}
|
||||
|
||||
public void Update(float deltaTime)
|
||||
{
|
||||
if (BrakeInput <= 0) return;
|
||||
|
||||
float brakeTorque = BrakeInput * MaxBrakeTorque;
|
||||
_wheelSystem.ApplyTorque(-brakeTorque, deltaTime);
|
||||
}
|
||||
|
||||
public float GetBrakeTorque()
|
||||
{
|
||||
return BrakeInput * MaxBrakeTorque;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user