FFB Input Provider (Steering Wheel Support)
FFBInputProvider adds steering wheel support with force feedback (FFB) to NWH Vehicle Physics 2 using the DirectInput API. It works with any DirectInput-compatible device including Logitech, Thrustmaster, Fanatec, Moza, Simagic, Simucube, and other manufacturers.
Warning: This script requires two front wheels to function.
Features
- Physics-based force feedback using self-aligning torque (SAT) equation
- Support for all DirectInput-compatible steering wheels
- Per-vehicle FFB tuning via
FFBVehicleSettings - Suspension bump feedback (feel road surface through steering)
- Engine resonance effect (feel RPM at idle)
- Weight transfer feedback
- Collision effects
Compatible Devices
All DirectInput-compatible devices work, including:
| Device | Status |
|---|---|
| Simucube 2 Pro/Ultimate | Verified |
| Fanatec DD1/DD2/CSL DD | Verified |
| Moza R9 | Verified |
| Simagic Alpha | Verified |
| Logitech G29/G920/G923/PRO | Verified |
| Thrustmaster TX/T300 | Verified |
Setup
1. Install Unity-DirectInput Package
Add the Unity-DirectInput package via Unity Package Manager:
- Open Window > Package Manager
- Click the + button and select Add package from git URL
- Enter:
https://github.com/imDanoush/Unity-DirectInput.git - Click Install
- Restart Unity after installation
2. Import the DirectInput FFB Sample
- Open Window > Package Manager
- Find NWH Vehicle Physics 2 in the list
- Expand Samples
- Import DirectInput FFB Sample
3. Add FFBInputProvider to Scene
- Add the
FFBInputProviderprefab from the sample to your scene, OR - Add the
FFBInputProvidercomponent to any GameObject
The input provider will automatically detect and attach to the first FFB-capable device.
4. Configure Input Mappings
Configure your device's axis and button mappings via the DIInputManager component:
Default Axis Mappings:
- Steering: X axis (0-1 range)
- Throttle: Y axis
- Brake: Z rotation
- Clutch: Z axis
Default Button Mappings:
- Shift Up/Down: Paddles or sequential shifter
- H-Pattern: Buttons for each gear position
FFBInputProvider Settings
Hardware Configuration
| Setting | Description |
|---|---|
wheelbaseTorque |
Maximum torque output of your wheel in Nm. Examples: G29 = 2-3 Nm, T300 = 4-5 Nm, CSL DD = 5-8 Nm, Simucube Pro = 25 Nm |
deviceRotationRange |
Physical wheel's maximum rotation in degrees (e.g., 900) |
steeringSensitivity |
Multiplier for steering input |
Force Feedback Settings
| Setting | Description |
|---|---|
overallEffectStrength |
Master multiplier for all FFB forces (0 = disabled) |
casterAngle |
Caster geometry for mechanical trail. 3-7 for road cars, 8-12 for race cars |
centeringForceStrength |
Strength of centering based on suspension compression |
lowSpeedFriction |
Steering resistance when stationary |
friction |
Steering resistance at speed |
collisionEffectMultiplier |
Multiplier for collision impact feedback |
Effect Curves
| Setting | Description |
|---|---|
forceFeedbackEffect |
Curve controlling FFB strength vs steering angle |
springEffect |
Curve controlling centering force vs steering angle |
Secondary Effects
| Setting | Description |
|---|---|
suspensionBumpStrength |
Feel road surface (curbs, potholes) through steering |
suspensionBumpThreshold |
Minimum suspension velocity (m/s) to trigger bump feedback. Lower = more sensitive |
longitudinalWeightTransferStrength |
Heavier steering under braking, lighter under acceleration |
engineResonanceStrength |
Feel engine vibration at idle |
engineResonanceRpmFalloff |
How quickly engine resonance fades as RPM increases. Higher = fades faster |
engineResonanceSpeedFalloff |
Speed (m/s) at which engine resonance is halved. Road feedback dominates at higher speeds |
trueCenterSpringStrength |
Force pulling wheel to true center |
collisionEffectMultiplier |
Multiplier for collision impact feedback |
collisionWaitDuration |
Duration (seconds) to disable FFB forces after collision impact (0.05-1.0) |
Per-Vehicle Tuning
Add the FFBVehicleSettings component to your VehicleController GameObject for per-vehicle FFB customization.
Force Scaling
| Setting | Description |
|---|---|
overallCoeff |
Overall FFB strength multiplier |
satCoefficient |
Self-aligning torque strength |
mechanicalTrailCoeff |
Mechanical trail contribution (0 = pneumatic only, 0.35 = realistic) |
centeringCoeff |
Centering force multiplier |
Steering Geometry
| Setting | Description |
|---|---|
casterAngle |
Vehicle-specific caster angle (0 = use global) |
wheelRotationRange |
Steering wheel rotation for this vehicle |
Friction
| Setting | Description |
|---|---|
frictionCoeff |
At-speed friction multiplier |
lowSpeedFrictionCoeff |
Stationary friction multiplier |
Advanced Physics
| Setting | Description |
|---|---|
longitudinalCoeff |
Braking/acceleration torque contribution |
scrubRadius |
Scrub radius in meters (typical: 0.01-0.03m) |
scrubEffectStrength |
Tire scrub vibration intensity |
relaxationTime |
Force filtering time (lower = responsive, higher = smooth) |
Troubleshooting
Device Not Detected
- Ensure Unity-DirectInput package is installed
- Restart Unity after installation
- Check that your device appears in Windows Game Controllers
- Try disconnecting and reconnecting the device
Slow Enumeration
DirectInput device enumeration can occasionally take up to 60 seconds due to a Windows bug. USB Audio DACs and certain keyboards (e.g., Corsair) can cause this. Try disconnecting non-essential USB devices.
Force Feedback Not Working
- Verify
overallEffectStrengthis greater than 0 - Check
wheelbaseTorquematches your wheel's actual torque output - Ensure the vehicle has at least 2 front wheels with WheelControllers
- Check DIInputManager shows your device as FFB-capable
Requirements
- Unity-DirectInput package
- Unity's Input System package
- Windows 10/11 (DirectInput is Windows-only)
- DirectInput-compatible steering wheel with force feedback