Input

The Camera System supports the new Input System Package, the legacy Input Manager, and even custom input handlers. This is configured via the Input module.

Input is managed by the Input Manager which can be accessed from the Camera Controller and has the following available properties:

  • Settings: The active input settings (Read only).

  • Handler: The active input handler (Read only).

  • Enabled: Turns on/off input handling.


🎛ī¸ Input Handlers


Input System Package

It is recommended to use Unity's new Input System Package as it offers a more flexible and powerful input system, and the Camera System already has predefined input actions for every module.

Assuming you have the aforementioned package installed, choose the Input System Package (New) option from the handler dropdown in the input settings to use this handler.

Once selected, a new field will show up to provide an .inputactions asset. This is a custom asset provided by the Input System package that allows you to provide input bindings for every action in your game. The Camera System comes with a default set of input actions, but you'll likely want to use your own.


Legacy Input Manager

Choose the Input Manager (Old) option from the handler dropdown in the input settings to use the legacy Input Manager.

All inputs are defined in Edit > Project Settings > Input Manager, per usual. It'll be up to you to define any missing inputs for your game, otherwise you'll receive a warning in the console.


Custom Input Handler

Choose the Custom option from the handler dropdown in the input settings to provide your own input handler. This may be needed if you are using an input system from the Asset Store or you rolled your own.

Once selected, a new field will show up to provide a Custom Handler asset. To do this, you'll need to create a new script that inherits from a custom scriptable object type InputHandler. Here's an example:

using UnityEngine;
using Zigurous.CameraSystem.Input;

[CreateAssetMenu(menuName = "Camera System/Custom Input Handler")]
public class CustomInputHandler : InputHandler
{
    public override float GetAxis(InputAxis axis)
    {
        // Return the input value for the input axis
    }

    public override bool GetButtonHeld(InputButton button)
    {
        // Return true while the input button is held down
    }

    public override bool GetButtonPressed(InputButton button)
    {
        // Return true during the frame the input button is pressed
    }

    public override bool GetButtonReleased(InputButton button)
    {
        // Return true during the frame the input button is released
    }
}

The overriden methods must be implemented to handle input from the camera system.

The [CreateAssetMenu] attribute allows the class to be instantiated as an asset at the specified menu path. Upon creating the asset, you can then assign it to the Custom Handler field in the input settings.


🕹ī¸ Input Types


Input Axis

The Input Axis data structure is used to define axis inputs, such as for looking around.

  • Name: The name of the input axis as defined in the .inputsettings asset or the Input Manager depending on the chosen input handler.

  • Sensitivity: The input sensitivity multiplier (default=1).

  • Inverted: Inverts the input axis value, e.g., if the input is 1, then the value becomes -1.

  • Timescaled: Scales the input axis value by delta time.


Input Button

The Input Button data structure is used to define button inputs, such as when locking onto a target. Whether the button is pressed, released, or held is determined by the modules that use it.

  • Name: The name of the input button as defined in the .inputsettings asset or the Input Manager depending on the chosen input handler.

🧰 Scripting API