new cars and maps

This commit is contained in:
Valera 2025-11-21 17:52:25 +07:00
parent 558a1eda07
commit 6cb8f716b3
8 changed files with 45 additions and 9 deletions

View File

@ -117,10 +117,10 @@ public partial class Clutch : PowertrainComponent
ClutchInput = 1f; ClutchInput = 1f;
} }
if ( Controller.SwappedBrakes > 0 ) //if ( Controller.SwappedBrakes > 0 )
{ //{
ClutchInput = 0; // ClutchInput = 0;
} //}
} }
if ( Controller.IsClutching > 0 ) if ( Controller.IsClutching > 0 )
{ {

View File

@ -334,7 +334,7 @@ public class Engine : PowertrainComponent, IScenePhysicsEvents
// Calculate generated torque and power // Calculate generated torque and power
float generatedTorque = CalculateTorqueICE( OutputAngularVelocity, dt ); float generatedTorque = CalculateTorqueICE( OutputAngularVelocity, dt );
generatedPower = TorqueToPowerInKW( in OutputAngularVelocity, in generatedTorque ); generatedPower = TorqueToPowerInKW( in OutputAngularVelocity, in generatedTorque );
// Calculate reaction torque // Calculate reaction torque
float reactionTorque = (targetAngularVelocity - OutputAngularVelocity) * Inertia / dt; float reactionTorque = (targetAngularVelocity - OutputAngularVelocity) * Inertia / dt;

View File

@ -34,6 +34,8 @@ public abstract partial class VeloXBase
public float SwappedBrakes => IsInputSwapped ? Throttle : Brakes; public float SwappedBrakes => IsInputSwapped ? Throttle : Brakes;
public bool AnyInput => Throttle > 0 || Brakes > 0;
[Sync] [Sync]
public float VerticalInput public float VerticalInput
{ {
@ -106,7 +108,11 @@ public abstract partial class VeloXBase
} }
protected void UpdateInput() protected void UpdateInput()
{ {
VerticalInput = Input.AnalogMove.x; //VerticalInput = Input.AnalogMove.x;
Brakes = Input.Brake;
Throttle = Input.Throttle;
Handbrake = Input.Down( "Handbrake" ) ? 1 : 0; Handbrake = Input.Down( "Handbrake" ) ? 1 : 0;
SteeringAngle = Input.AnalogMove.y; SteeringAngle = Input.AnalogMove.y;

View File

@ -42,12 +42,12 @@ public abstract partial class VeloXBase
} }
else else
{ {
v.BrakeTorque = SwappedBrakes * BrakeForce * 0.7f; v.BrakeTorque = SwappedBrakes * BrakeForce * 0.2f;
v.BrakeTorque += Handbrake * HandbrakeForce; v.BrakeTorque += Handbrake * HandbrakeForce;
} }
if ( TotalSpeed < 1 && Input.AnalogMove.x == 0 ) if ( TotalSpeed < 1 && !AnyInput )
{ {
v.BrakeTorque = HandbrakeForce; v.BrakeTorque = HandbrakeForce;
} }

View File

@ -249,7 +249,8 @@ public partial class VeloXWheel
{ {
lowSpeedReferenceIsSet = false; lowSpeedReferenceIsSet = false;
} }
ForwardFriction.Force = Math.Clamp( ForwardFriction.Force, -peakForwardFrictionForce, peakForwardFrictionForce );
ForwardFriction.Force = Math.Clamp( ForwardFriction.Force * Tire.Evaluate( Math.Abs( ForwardFriction.Slip ) ), -peakForwardFrictionForce, peakForwardFrictionForce );
SidewayFriction.Force = Math.Clamp( SidewayFriction.Force, -peakSideFrictionForce, peakSideFrictionForce ); SidewayFriction.Force = Math.Clamp( SidewayFriction.Force, -peakSideFrictionForce, peakSideFrictionForce );

View File

@ -1,4 +1,5 @@
using Sandbox; using Sandbox;
using System;
namespace VeloX; namespace VeloX;

View File

@ -61,6 +61,7 @@ public partial class VeloXWheel : Component
internal void Update( VeloXBase vehicle, in float dt ) internal void Update( VeloXBase vehicle, in float dt )
{ {
UpdateVisuals( vehicle, dt ); UpdateVisuals( vehicle, dt );
} }
private void UpdateVisuals( VeloXBase vehicle, in float dt ) private void UpdateVisuals( VeloXBase vehicle, in float dt )

View File

@ -1,6 +1,7 @@
using Sandbox; using Sandbox;
namespace VeloX; namespace VeloX;
public class InputResolver public class InputResolver
{ {
public Connection Driver { get; internal set; } public Connection Driver { get; internal set; }
@ -30,6 +31,27 @@ public class InputResolver
return IsDriverActive && Input.Down( action ); return IsDriverActive && Input.Down( action );
} }
public float Brake
{
get
{
if ( Input.UsingController )
return Input.GetAnalog( InputAnalog.LeftTrigger );
return Input.Down( "Brake" ) ? 1 : 0;
}
}
public float Throttle
{
get
{
if ( Input.UsingController )
return Input.GetAnalog( InputAnalog.RightTrigger );
return Input.Down( "Throttle" ) ? 1 : 0;
}
}
public bool Pressed( string action ) public bool Pressed( string action )
{ {
return IsDriverActive && Input.Pressed( action ); return IsDriverActive && Input.Pressed( action );
@ -40,6 +62,11 @@ public class InputResolver
return IsDriverActive && Input.Released( action ); return IsDriverActive && Input.Released( action );
} }
public float GetAnalog( InputAnalog analog )
{
return IsDriverActive ? Input.GetAnalog( analog ) : 0f;
}
public void TriggerHaptics( float leftMotor, float rightMotor, float leftTrigger = 0f, float rightTrigger = 0f, int duration = 500 ) public void TriggerHaptics( float leftMotor, float rightMotor, float leftTrigger = 0f, float rightTrigger = 0f, int duration = 500 )
{ {
if ( IsDriverActive ) if ( IsDriverActive )