⮞ Go to NeoFPS.com

    Show / Hide Table of Contents

    Input System Extension

    Overview

    The Input System extension adds alternative versions of each of the NeoFPS input handlers and the input manager which use the input system instead of old input manager. The input system adds much better support for gamepad controllers, along with an action map editor that can be used to quickly add new input actions to your game.

    As of NeoFPS 1.1.36, the NeoFPS demos are setup for URP and the input system in Unity 6 and above. In Unity versions below Unity 6, the demos are set up to use the built-in render pipeline and the legacy input manager.

    If you are using Unity 6 or above, then any new project will be correctly set up for NeoFPS and the input system. You only need to import NeoFPS from the package manager and run the quick setup tools in the NeoFPS Hub.

    The below information and instructions are for users of older Unity versions than Unity 6 who want to switch the NeoFPS demos (and their project) to using the input system.

    Installation

    Installing the Input System

    Before extracting the extension you will need to make sure that the input system is installed and activated:

    • Make sure that the Active Input Handling property in the Player Settings/Other Settings section is set to Both.
    • Import the Input System package in the package manager (minimum version 1.1.1).

    Package Manager

    Note: The package manager might look different based on your Unity version. Consult Unity's documentation if you have trouble finding the required package

    Importing the Extension Package

    Setup and Use

    Note: make sure to take a backup of your project before making major changes like these

    Once the extension package has been imported you should follow these steps to start using the input system with NeoFPS:

    1. Find the old input manager at NeoFPS/Resources/FpsManager_Input, and move it out of the Resources folder or delete it.
      • You will need to close and reopen the NeoFPS hub if you had it open at this point as it will be pointing at the old input manager.
    2. Replace all input handler components (you can see a list below) on your weapons, characters and other prefabs with the equivalent input system versions.
      • In 1.1.26 a tool was added to automatically convert input handlers on prefabs in the project. You can access this in the Unity menus at: Tools/NeoFPS/Input Handler (you need to have imported the extension package before these tools appear). There is one option to convert input handlers to the input system, and one to convert them back to the legacy input manager. This will also transfer any settings. Warning: this tool modifies your project files and can not be undone. Always back up your project before making changes like this (or better yet, use version control such as Git).
    3. Modify your menu prefabs to use the new input system based rebinding options panel
      • Open your menu prefabs (eg InGameMenu and MainMenu) and under the Panels object delete the OptionsPanel_Bindings object
      • Replace that object with the OptionsPanel_InputSystemBindings from the NeoFPS/Extensions/InputSystem/SampleUI folder
      • In the menu hierarchy, expand MenuObject/NavControls/NavControls_Options and select the Button_Bindings object
      • In the MultiInputButton component, in the On Click() event, drag the new OptionsPanel_InputSystemBindings object onto the parameter that currently says None (Menu Panel)

    Input Handlers

    The following input system based input handlers are provided, which replace the input handlers used in the demo assets:

    Name Replaces Description
    InputSystemAbilityFirearm InputAbilityFirearm This is attached to a (non-inventory based) firearm in the character's hierarchy to trigger it with the ability button. An example is the shoulder mounted missile launchers in the jetpacks and guided missiles demo.
    InputSystemCharacterMotion InputCharacterMotion This is attached to the root of the player character and sends input to the motion controller.
    InputSystemCharacterSlowMo InputCharacterSlowMo This is attached to the root of the player character and triggers slow motion effects using the ability button.
    InputSystemFirearm InputFirearm This is attached to the root of a firearm prefab and sends it the required weapon input.
    InputSystemFirearmWithMelee InputFirearmWithMelee This is attached to the root of a firearm prefab that also has a Melee Weapon behaviour attached. It acts just as the firearm input above, but adds an extra control to trigger the melee attack.
    InputSystemGame InputGame This is a placeholder input handler that can be extended to add game specific functionality such as showing a scoreboard. An example is placed on the player controller (not character) prefab.
    InputSystemInventory InputInventory This is attached to the root of the player character and handles weapon selection and dropping items.
    InputSystemLockpick InputLockpick This is attached to a lockpick popup prefab such as the InteractableDoors_LockpickPopup3D prefab found in the interactable doors demo folder.
    InputSystemMeleeWeapon InputMeleeWeapon This is attached to the root of a melee weapon prefab and sends it the required weapon input.
    InputSystemMenu InputMenu This is attached to a custom (non-NeoFPS) UI/menu object and disables character input when activated and restores it when deactivated.
    InputSystemThrownWeapon InputThrownWeapon This is attached to the root of a thrown weapon prefab and sends it the required weapon input.
    InputSystemVehicle InputVehicle This is a placeholder input handler that can be attached to a vehicle to block character input.
    InputSystemWieldableTool InputWieldableTool This is attached to the root of a wieldable tool prefab and sends it the required tool input.
    MenuInputSystemToggle UiInputToggle This is extended from the InputSystemMenu component above and adds properties and methods to manually toggle the UI visibility instead of reacting to the UI object's state.

    You can find the existing input handlers attached to the following objects:

    • The root object of any weapon or tool (InputFirearm, InputMeleeWeapon, InputThrownWeapon, InputWieldableTool)
    • The root of the character (InputCharacterMotion, InputInventory, InputCharacterSlowMo, etc)
    • The player prefab (InputGame)
    • Ability weapon prefabs (InputAbilityWeapon)
    • Custom UI menus, not including the demo UIs (InputMenu)
    • Lockpick UI prefabs (InputLockpick)

    Touch controls

    Touch controls

    A number of touch controls are available for touchscreen input. The input system contains replacement versions of each of them. Inside the Assets/InputSystem/Touchscreen folder you will find the scripts that are equivalent to the input manager based touch controls. Inside the Assets/InputSystem/Prefabs folder you will find touchscreen versions of the HUD and menu prefabs. Replacing the HudAndMenuCanvas or HudAndMenuCanvas_Touch in your scene with HudAndMenuCanvas_InputSystemTouch should be all you need to get started.

    For more information on using touch controls in NeoFPS, see Touchscreen Input.

    Known Issues

    The input system is a vast improvement on the old input manager with regards to gamepad controls and device agnostic input. However it does have some longstanding bugs, and the rebinding system is not as well rounded as it could be. There are 3 main areas where I feel it causes problems that might not be solveable until the input system itself is changed:

    • The main visible issue that you will see is that the display name for keyboard keys looks good for the generic keyboard (as specified in the actions asset when defining the controls for actions), but when switching to a specific keyboard (ie when rebinding), the display name will just return the enum for the key. This means that on first setup a key such as left-shift will appear as "Left Shift" in the rebinding UI, but if you try to map that to another key it will appear as "leftShift".
    • There is no in-built system for gamepad profiles, and the NeoFPS solution works by using the rebinding system to rebind each button individually. This means a lot of complicated code that overlaps with the keyboard rebinding quite heavily and might be more fragile than it should be.
    • The way the code generation works for the input asset locks the architecture down in a way that makes it very hard to extend (eg when using NeoFPS alongside other assets). In a future update (probably the 1.2 upgrade as mentioned below) the system will be switched away from using the code generation, and just tie into the action IDs on the asset directly (in a similar way to the Unity UI InputSystemEventHandler).

    Future Development

    For the upcoming 1.2 upgrade, NeoFPS will switch over to a new input setup that allows switching between the legacy unity input manager, unity input system, or even rewired via the project settings page in the NeoFPS Hub. This will handle the importing and setup of the input handlers for you.


    See Also

    Touchscreen Input

    Back to top Copyright © 2019 Yondernauts Game Studios Ltd
    Generated with DocFX