diff --git a/Code/Base/Powertrain/WheelPowertrain.cs b/Code/Base/Powertrain/WheelPowertrain.cs index ce17662..f2a0a27 100644 --- a/Code/Base/Powertrain/WheelPowertrain.cs +++ b/Code/Base/Powertrain/WheelPowertrain.cs @@ -51,7 +51,7 @@ public partial class WheelPowertrain : PowertrainComponent Wheel.AutoSimulate = false; Wheel.StepPhys( Controller, dt ); - + return Math.Abs( Wheel.CounterTorque ); } diff --git a/Code/Base/VeloXBase.Input.cs b/Code/Base/VeloXBase.Input.cs index 602f507..4b69920 100644 --- a/Code/Base/VeloXBase.Input.cs +++ b/Code/Base/VeloXBase.Input.cs @@ -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() { diff --git a/Code/Base/VeloXBase.Sound.cs b/Code/Base/VeloXBase.Sound.cs index a5b0942..1435ce6 100644 --- a/Code/Base/VeloXBase.Sound.cs +++ b/Code/Base/VeloXBase.Sound.cs @@ -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 ); } } } diff --git a/Code/Input/InputResolver.cs b/Code/Input/InputResolver.cs index e7a2a89..f04e590 100644 --- a/Code/Input/InputResolver.cs +++ b/Code/Input/InputResolver.cs @@ -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() {