This commit is contained in:
Valera 2025-11-12 21:57:11 +07:00
parent ab8cc70785
commit 97fcb29bc0
4 changed files with 36 additions and 7 deletions

View File

@ -105,15 +105,15 @@ public abstract partial class VeloXBase
}
private void UpdateInput()
{
VerticalInput = TotalSpeed < 10 ? Input.AnalogMove.x * 0.5f : Input.AnalogMove.x;
Handbrake = Input.Down( "Jump" ) ? 1 : 0;
VerticalInput = Input.AnalogMove.x;
Handbrake = Input.Down( "Handbrake" ) ? 1 : 0;
SteeringAngle = Input.AnalogMove.y;
IsClutching = (Input.Down( "Run" ) || Input.Down( "Jump" )) ? 1 : 0;
IsClutching = Input.Down( "Clutch" ) ? 1 : 0;
IsShiftingUp = Input.Pressed( "Attack1" );
IsShiftingDown = Input.Pressed( "Attack2" );
IsShiftingUp = Input.Pressed( "Shift Up" );
IsShiftingDown = Input.Pressed( "Shift Down" );
if ( TotalSpeed < 150 && Driver is null )
Handbrake = 1;
@ -143,6 +143,13 @@ public abstract partial class VeloXBase
Input.TriggerHaptics( leftMotor, rightMotor, leftTrigger, rightTrigger, duration );
}
}
public void TriggerHaptics( HapticEffect effect, float lengthScale = 1, float frequencyScale = 1, float amplitudeScale = 1 )
{
if ( IsDriverActive )
{
Input.TriggerHaptics( effect, lengthScale, frequencyScale, amplitudeScale );
}
}
public void StopAllHaptics()
{

View File

@ -52,11 +52,13 @@ public abstract partial class VeloXBase : Component, Component.ICollisionListene
{
var hardSound = Sound.Play( HardCollisionSound, WorldPosition );
hardSound.Volume = volume;
TriggerHaptics( HapticEffect.HardImpact );
}
else if ( surfaceNormal.Dot( -collision.Contact.Speed.Normal ) < 0.5f )
{
var scrapSound = Sound.Play( VehicleScrapeSound, WorldPosition );
scrapSound.Volume = 0.4f;
TriggerHaptics( HapticEffect.SoftImpact );
}
}
}

View File

@ -10,7 +10,20 @@ public class InputResolver
public Vector2 MouseDelta => IsDriverActive ? Input.MouseDelta : default;
public Vector2 MouseWheel => IsDriverActive ? Input.MouseWheel : default;
public Angles AnalogLook => IsDriverActive ? Input.AnalogLook : default;
public Vector3 AnalogMove => IsDriverActive ? Input.AnalogMove : default;
public Vector3 AnalogMove
{
get
{
if ( Input.UsingController )
{
Vector2 input = 0;
input.x = Input.GetAnalog( InputAnalog.RightTrigger ) - Input.GetAnalog( InputAnalog.LeftTrigger );
input.y = -Input.GetAnalog( InputAnalog.LeftStickX );
return input;
}
return IsDriverActive ? Input.AnalogMove : default;
}
}
public bool Down( string action )
{
@ -34,6 +47,13 @@ public class InputResolver
Input.TriggerHaptics( leftMotor, rightMotor, leftTrigger, rightTrigger, duration );
}
}
public void TriggerHaptics( HapticEffect effect, float lengthScale = 1, float frequencyScale = 1, float amplitudeScale = 1 )
{
if ( IsDriverActive )
{
Input.TriggerHaptics( effect, lengthScale, frequencyScale, amplitudeScale );
}
}
public void StopAllHaptics()
{