### Implement Custom VehicleInputProvider
Source: https://www.nwhvehiclephysics.com/doku.php/NWH/Common/Input/InputManagerSceneInputProvider
Example implementation of a custom input provider using VehicleInputProviderBase.
```csharp
using NWH.Common.Input;
using UnityEngine;
using UnityEngine.InputSystem;
///
/// Example class for handling input.
///
public class CustomVehicleInputProvider : VehicleInputProviderBase
{
public override void Awake()
{
base.Awake();
// Your initialization code here (if needed). Just a standard MonoBehaviour Awake().
}
public void Update()
{
// Your Update() code here (if needed). Just a standard MonoBehaviour Update().
}
public override Throttle()
{
// Return your custom value here, example:
return 0.5f; // Replace this line with e.g. player.GetAxis("Throttle") for Rewired.
}
public override Steering()
{
// Return your custom steering value here.
return 0.123f;
}
// ...and so on. Override the functions that you want to use. If you do not need Clutch() for example,
// do not override it.
}
```
--------------------------------
### Retrieve a Module
Source: https://www.nwhvehiclephysics.com/doku.php/Setup/VehicleController
Access a module instance by getting its wrapper component and casting the internal module property.
```csharp
MyModule module = myVehicleController.GetComponent().module as MyModule;
```
--------------------------------
### Create Custom InputProvider Class
Source: https://www.nwhvehiclephysics.com/doku.php/NWH/Common/Input/InputManagerSceneInputProvider
Inherit from VehicleInputProvider to define custom input logic.
```csharp
public class ExampleVehicleInputProvider : VehicleInputProvider{}
```
--------------------------------
### Control Throttle and Brake via Code
Source: https://www.nwhvehiclephysics.com/doku.php/NWH/Common/Input/InputManagerSceneInputProvider
Demonstrates setting vertical input to control throttle and brake axes manually.
```csharp
vehicleController.input.autoSetInput = false; // Tells the vehicle to stop retrieving input values automatically.
vehicleController.input.Vertical = 0.5f; //Sets throttle to 0.5f, resets brakes.
vehicleController.input.Vertical = -0.5f; //Sets brakes to 0.5f, resets throttle.
```
--------------------------------
### Add a Module via Scripting
Source: https://www.nwhvehiclephysics.com/doku.php/Setup/VehicleController
Add a module wrapper to the vehicle's GameObject. Modules should be added before play mode or immediately after VehicleController initialization.
```csharp
myVehicleController.gameObject.AddComponent();
```
```csharp
myVehicleController.gameObject.AddComponent();
```
--------------------------------
### Retrieve Individual Input
Source: https://www.nwhvehiclephysics.com/doku.php/NWH/Common/Input/InputManagerSceneInputProvider
Access specific InputProvider instances directly by index.
```csharp
float throttle = InputProvider.Instances[0].Throttle;
```
--------------------------------
### Enable or Disable a Module
Source: https://www.nwhvehiclephysics.com/doku.php/Setup/VehicleController
Toggle module state using the inherited VehicleComponent methods. Manual settings are overridden if LODs are active.
```csharp
myModule.VC_Enable();
```
```csharp
myModule.VC_Disable();
```
--------------------------------
### Modify VehicleComponent state via scripting
Source: https://www.nwhvehiclephysics.com/doku.php/NWH/VehiclePhysics2/VehicleComponent
Use these methods to programmatically control component activation and LOD settings. Setting LodIndex to -1 is required to prevent LOD logic from overriding manual state changes.
```csharp
myVehicleComponent.LodIndex = -1; // IMPORTANT! Setting this to -1 disables the
// LODs which otherwise override the enabled/disabled setting.
myVehicleComponent.VC_Enable();
myVehicleComponent.VC_Disable();
```
--------------------------------
### Retrieve Combined or Individual Input
Source: https://www.nwhvehiclephysics.com/doku.php/NWH/Common/Input/InputSystemSceneInputProvider
Use CombinedInput to aggregate values from all active providers, or access specific instances directly via the Instances array.
```csharp
float throttle = InputProvider.CombinedInput(i => i.Throttle());
bool engineStartStop = InputProvider.CombinedInput(i => i.EngineStartStop());
```
```csharp
float throttle = InputProvider.Instances[0].Throttle;
```
--------------------------------
### Retrieve Combined Input
Source: https://www.nwhvehiclephysics.com/doku.php/NWH/Common/Input/InputManagerSceneInputProvider
Use CombinedInput to aggregate values from all active InputProviders in the scene.
```csharp
float throttle = InputProvider.CombinedInput(i => i.Throttle());
bool engineStartStop = InputProvider.CombinedInput(i => i.EngineStartStop());
```
--------------------------------
### Manually Set Input
Source: https://www.nwhvehiclephysics.com/doku.php/NWH/Common/Input/InputManagerSceneInputProvider
Set autoSetInput to false to disable automatic fetching and manually assign values to input properties or states.
```csharp
myVehicleController.input.Horizontal = myFloatValue; // Using getter/setter.
```
```csharp
myVehicleController.input.states.horizontal = myFloatValue; // Directly accessing states.
```
--------------------------------
### Implementing Engine Power Modifiers
Source: https://www.nwhvehiclephysics.com/doku.php/Setup/VehicleController
Use power modifiers to dynamically adjust engine power output via scripting. The modifier function must return a float coefficient and be added to the engine's powerModifiers list.
```csharp
public float AddBoost()
{
if(boostIsActive)
{
return 1.5f; // Increases power for 50%.
}
}
...
myVehicleController.powertrain.engine.powerModifiers.Add(AddBoost);
```
--------------------------------
### Access Input States
Source: https://www.nwhvehiclephysics.com/doku.php/NWH/Common/Input/InputManagerSceneInputProvider
Directly reference the input states struct of a vehicle controller.
```csharp
myVehicleController.input.states
```