parent
2ad29e481f
commit
72d66e5984
|
@ -51,12 +51,12 @@ public enum Axel
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// inputs for acceleration
|
/// inputs for acceleration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private float _currentAcceleration;
|
[SerializeField] private float _currentAcceleration;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// inputs for turning
|
/// inputs for turning
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private float _currentTurn;
|
[SerializeField] private float _currentTurn;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// to move the car
|
/// to move the car
|
||||||
|
@ -82,7 +82,8 @@ public void SetInputs(float forwardAmount, float turnAmount)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Move()
|
public void Move()
|
||||||
{
|
{
|
||||||
foreach (var wheel in wheels) wheel.wheelCollider.motorTorque = _currentAcceleration;
|
foreach (var wheel in wheels)
|
||||||
|
wheel.wheelCollider.motorTorque = _currentAcceleration;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -103,8 +104,12 @@ public void Brake()
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Steering()
|
public void Steering()
|
||||||
{
|
{
|
||||||
foreach (var wheel in wheels.Where(wheel => wheel.axel == Axel.Front))
|
foreach (var wheel in wheels)
|
||||||
wheel.wheelCollider.steerAngle = _currentTurn;
|
if (wheel.axel == Axel.Front)
|
||||||
|
{
|
||||||
|
wheel.wheelCollider.steerAngle = _currentTurn;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Reference in a new issue