Combining Input Origins

Use multiple input keys to combine different input origins into a single input key.

Input keys are pretty straight forward – they get input from an input origin (e.g. keyboard key via Key Code) and make it available where you use the input key (e.g. for menu controls or to use battle actions via control maps).

While you can add multiple input origins to a single input key, those are used to e.g. switch control styles by changing the game’s Input ID – i.e. adding multiple input origins with the same input ID to an input key doesn’t work, the first matching input ID will be used in that case.

Instead, we can use multiple input keys to combine input from different origins, e.g. keyboard and controller input. This is done using the Input Key input origin, which allows us to use other input keys to get input from.

E.g. to combine input from keyboard and controller, we need 3 input keys:

  • Keyboard Key
    The input key getting input from a keyboard key.
  • Controller Key
    The input key getting input from a controller button.
  • Combined Key
    The input key getting input from Keyboard Key and Controller Key.
    This is the input key that’ll be used in other settings.

Let’s do that – in this tutorial we’ll set up input keys to combine keyboard and controller input origins.

Tip: Ready-to-use controller setups #

You can download ready-to-use input key setups for XBox and PlayStation controllers containing all buttons, triggers and sticks.

They’re available in the Makinom extensions and can also be directly downloaded and imported via the Makinom Extension Manager in the Unity menu: Window > Gaming Is Love > Makinom Extension Manager

Input Key Setup #

As an example, we’ll combine the keyboard key Space and the controller button Joystick Button 0. Both are available via Key Code input origin.

Open the Makinom editor and navigate to Base/Control > Input Keys.

Keyboard Key: Space #

Add a new input key and change the following settings.

Content Information #

  • Name
    Set to Space.

Input ID Setting 0 #

  • Input Origin
    Select Key Code.
  • Positive Key
    Select Space.

Controller Button: Button 0 #

Add a new input key and change the following settings.

Content Information #

  • Name
    Set to Button 0.

Input ID Setting 0 #

  • Input Origin
    Select Key Code.
  • Positive Key
    Select Joystick Button 0.

Combined Input #

Add a new input key and change the following settings.

Content Information #

  • Name
    Set to Combined Input.
    Or any other name you want to use.

Input ID Setting 0 #

  • Input Origin
    Select Input Key.
  • Needed
    Select One.
    We only need input from one of the input keys.
    If you want to combine inputs, i.e. require input from multiple keys (e.g. Shift + Space), select All instead.

Click on Add Input Key.

  • Input Key
    Select Space.

Click on Add Input Key again to add another input.

  • Input Key
    Select Button 0.

Save Changes #

And that’s it for the input key setup.

Don’t forget to save your changes by clicking on Save Settings at the bottom of the editor.

Using the combined input key #

You can use an input key combining other input keys like any other input key, i.e. simply select it where you want to use it.

Make sure you use the combined input key instead of the other input keys (e.g. in this example, the Combined Key instead of Space or Button 0).