AircraftInputManager
retrieves input from activeInputProvider
and fills theInputStates
struct with the retrieved data.InputProvider
s are split into AircraftInputProviders and SceneInputProviders. AircraftInputProviders relay vehicle input (throttle, yoke, etc.) while SceneInputProviders take care of scene input (vehicle changing, camera changing, camera movement and the rest of the inputs not directly related to vehicle. One of each needs to be present (e.g.InputSystemVehicleProvider
andInputSystemSceneInputProvider
).- Multiple different
InputProvider
s can be present in the scene. E.g. InputSystemProviders and MobileInputProviders can be used in the same scene. The resulting input will be a sum of inputs from allInputProvider
s in case of numeric inputs and logical OR operation of all inputs in case of boolean inputs. - Input is stored inside the
InputStates
object and can be copied over from one vehicle to another. E.g. this is what is done when a trailer is connected to a towing vehicle. - To manually set the
InputStates
make sureAuto Settable
is set to false.
All input providers inherit from either AircraftInputProviderBase
or SceneInputProviderBase
, but differ in their implementation.
Input System Warning
When importing the asset for the first time this message will pop up:
Both Yes
or No
can be selected but it is important to set the Project Settings ⇒ Player ⇒ Input Handling to Both
afterwards. This way both new InputSystem and the old InputManager will work. If this setting is set to InputManager
only errors might appear as the demo scenes of the asset rely on InputSystem.
If a message This Unity Package has Package Manager dependencies. appears, click Install/Upgrade
.
Available Bindings
AircraftInput Provider Bindings
Out of the box gamepad bindings are only available for InputSystem.
Name | Type | Keyboard Defaults | Gamepad Defaults |
---|---|---|---|
Ailerons | axis | A/D | LS - Horizontal |
AileronsTrimLeft | button | H | Button North + Right |
AileronsTrimRight | button | K | Button North + Left |
Rudder | axis | Q/E | L/R Trigger |
RudderTrimLeft | button | Y | |
RudderTrimRight | button | I | |
Elevator | axis | W/S | LS - Vertical |
ElevatorTrimUp | button | U | Button North + Up |
ElevatorTrimDown | button | J | Button North + Down |
FlapsExtend | button | F7 | Right Shoulder |
FlapsExtendFully | button | F8 | |
FlapsRetract | button | F6 | Left Shoulder |
FlapsRetractFully | button | F5 | |
Spoilers | button | / | |
LandingLights | button | L | |
NavigationLights | button | K | |
LandingGear | button | G | |
EngineStartCommon | button | T | Button West |
EngineStopCommon | button | F | Button North + West |
ThrottleCommon | axis | F12 | |
ThrottleIdle | button | F1 | |
ThrottleIncrease | button | F3 | Button South |
ThrottleDecrease | button | F2 | Button North |
ThrottleFull | button | F4 | |
ParkingBrake | button | , | Button North + East |
Brakes | button | . | Button North |
BrakesLeft | button | - | |
BrakesRight | button | = | |
SmokeSystem | button | I | |
PropPitch | axis | F9/F10 | |
PropPitchIncrease | button | F12 | |
PropPitchDecrease | button | F11 |
Scene Input Provider Bindings
Name | Type | Keyboard Defaults | Gamepad Defaults | Description |
---|---|---|---|---|
ChangeCamera | button | C | Start | Changes camera. |
CameraRotation | 2D axis | Mouse Delta | Right Stick | Controls camera rotation. |
CameraPanning | 2D axis | Mouse Delta | Right Stick | Controls camera panning. |
CameraRotationModifier | button | Mouse - LMB | Right Stick Press | Enables camera rotation. |
CameraPanningModifier | button | Mouse - RMB | Left Stick Press | Enables camera panning. |
CameraZoom | axis | Mouse - Scroll | D-Pad Up/Down | Camera zoom in/out. |
ChangeVehicle | button | V | Select | Change vehicle or enter/exit vehicle. |
FPSMovement | 2D axis | WASD | Left Stick | Demo FPS controller movement. |
ToggleGUI | button | Tab | Toggles demo scene GUI. |
Input Manager (old/classic)
- Type of
InputProvider
for handling user input on desktop devices through keyboard and mouse or gamepad. - Uses classic/old Unity Input Manager. It is recommended to use the Unity's new Input System instead for new projects.
InputSystem package is required even if not used. If using the old/classic Unity input set Project Settings ⇒ Player ⇒ Input Handling to Both
and proceed as normal. InputSystem package being present installed will not interfere with old/classic Unity input / InputManager.
Installation
When first importing NWH Aerodynamics the project will be missing the required bindings in Unity Input Manager. There are two ways to add those:
- Manually adding each entry to the Project Settings ⇒ Input following the input bindings table.
- Copying the contents of InputBindings.txt and appending them to the contents of the
[UnityProjectPath]/ProjectSettings/InputManager.asset
file. To do so:- Close Unity.
- Open InputManager.asset in a text editor of your choice.
- Copy the contents of the provided InputBindings.txt file (NWH ⇒ Aerodynamics ⇒ Scripts ⇒ Input ⇒ InputProviders ⇒ InputManagerProvider ⇒ InputBindings.txt) and paste them at the end of the InputManager.asset. Make sure there are no empty lines between the existing content and the pasted content. Also make sure that all the indents are correct. Save the file.
- Open Unity. Check Project Settings ⇒ Input. The input bindings for NWH Aerodynamics will appear towards the bottom of the list.
Scene Setup
To set up InputManager-based input in the scene add the following components to the scene:
- 'InputManagerAircraftInputProvider'
- 'InputManagerSceneInputProvider'
Any vehicle that is present in the scene will now receive input from these providers.
Input System (new)
Installation
- Install 'Input System' package through Window ⇒ Package Manager
- Under Edit ⇒ Project Settings ⇒ Player ⇒ Other Settings ⇒
Active Input Handling select
Input System Package (New)
orBoth
- the latter in case your project still usesUnityEngine.Input
somewhere.
Scene Setup
- Add
InputSystemAircraftInputProvider
andInputSystemSceneInputProvider
to any object in your scene. - Default bindings can be modified by double clicking on
.inputactions
files.Save Asset
must be clicked for the changes to take effect.
Scripting
Retrieving Input
Multiple InputProvider
s can be present in the scene, meaning that their input has to be combined to get the final input result. To get the combined input use:
float ailerons = InputProvider.CombinedInput(i => i.Ailerons()); bool landingGear = InputProvider.CombinedInput(i => i.LandingGear());
Or to get the input from individual InputProvider
s (say to find out if a button was pressed on a keyboard):
float ailerons = InputProvider.Instances[0].Ailerons;
Manually Setting Input
Input in each vehicle is stored in InputStates
struct:
myAircraftInputManager.states
In case input should not be retrieved from user but from another script - as is the case when AI is used - AutoSettable
should be set to false
. This will disable automatic input fetching from the active InputProvider
s.
Input now can be set from any script:
myAircraftInputManager.Ailerons = myFloatValue;
Custom InputProvider
If a custom InputProvider
is needed it can easily be written. Custom InputProviders
allow for new input methods or for modifying the existing ones. E.g. if the MobileInputProvider
does not fit the needs of the project a copy of it can be made and modifications are done on that copy. That way it will not get overwritten when the asset is updated.
Steps to create a new InputProvider
:
- Create a new class, e.g.
ExampleInputProvider
and make it inherit fromAircraftInputProviderBase
orSceneInputProviderBase
classes. - Implement wanted methods. Most IDEs can do this automatically.