Input Basics (I)

(I) IMPORTANT: Understanding this section is vital to using Platformer PRO.


This section covers the basics of controlling a Character via an Input. An Input is any concrete implementation of the abstract Input class.


Quick Start

To quickly add an input to your game:

  1. Create an empty GameObject in your Scene.
  2. Select your newly created GameObject
  3. Press the AddComponent button.
  4. Add the StandardInput component to your GameObject (you can quickly find the component by typing its name).
  5. (Optional) You may want to press the Clear Preferences button on the Standard Input to ensure there are no Player Preferences set.


Overview of Input Classes

The following Input classes come with Platformer PRO:

Input Class Description Link
Standard Input The standard input is a flexible and powerful input class for desktop and consoles. Most games that aren't for mobile will use the StandardInput. Standard Input
Basic Touch Input A simple input for touch devices.  
Unity Input An Input class that allows you to use standard Unity input definitions.  
Buffered Input A special input class, which buffers the input from another input to provide more sensitive controls. You cannot use a buffered input by itself. Buffered Input
Multi Input An input class which provides a single interface in front of multiple other inputs. For example it allows you to have both keyboard and joystick configured simultaneously. Multi Input


How a Character find its Input

Although you can directly assign an Input to a character using the character s Input property if this is not assigned the character uses the following process to find an Input:

  1. Find all active Inputs in the scene.
  2. If none are found log an error.
  3. If one is found assign it.
  4. If two or more are found:
    1. Try to find a Buffered Input and assign it.
    2. If no Buffered Input is found, log a warning and assign the first Input found.


Action Buttons

Buttons like Jump and Run, Up and Down, are self explanatory but you may also need extra buttons in your game for things like using items or attacking. Action buttons allow you to define any number of arbitrary buttons.

When used in other components action buttons are identified by their array index. So for example if you define two buttons as follows:

And you want to use the second button (V) to attack you would set the action button index of the Attack to 1.

Tip: As with C# arrays are zero-indexed. In other words the first action button has the array index of 0.


Using Third-Party Input Systems

You can use other Input systems with Platformer PRO by wrapping them in your own implementation of the abstract class. For example if you were using cInput 2 (a popular third party Input asset) you might write a class as follows:

public class cInputWrapper : PlatformerPro.Input
  public string jumpButtonCInputName = "JUMP";
  override public ButtonState JumpButton
      if (cInput.GetKeyDown(jumpButtonCInputName)) return ButtonState.DOWN;
      if (cInput.GetKeyUp(jumpButtonCInputName)) return ButtonState.UP;
      if (cInput.GetKey(jumpButtonCInputName)) return ButtonState.HELD;
      return ButtonState.NONE

     // And so on for the rest of the methods ...


Unused Methods

Note that the Input class defines a number of abstract methods which allow in-game customisation of input. In many cases if you are using a third-party system these may not be applicable. Suggested implementation in these cases is something like: 

override public KeyCode GetKeyForType(KeyType type, int keyNumber)
  Debug.LogError ("This Input does not allow for in game control configuration.");
  return KeyCode.None;


Have more questions? Submit a request


  • 0
    John Avery

    Hi Kukuh,

    the in-built touch input uses sprites and colliders not uGUI. Its easiest to start with the prefab (for example the MultiPlatformInput prefab handles both keyboard and touch by activating the input that matches the current system). There's also a rough walk through at:

    You can use any input system by creating a wrapper around it that presents that systems input via the Input interface. The kit includes a sample wrapper for Unity's standard Input and also for the third party package Rewired. You could use these as samples.

    You may also want to post on the forums at some one else may have already created such a wrapper and be willing to share it (I certainly know of people who are using EasyTouch).

    Hope that helps.

    John A

    PS Just note that you need to use Unity remote to test the touch input in the Editor, it uses fingers and fingerId which gives more responsive control (but isn't sent by the mouse)

  • 0
    Kukuh Basuki

    Hi, i want to use Basic Touch Input. What should I do? Is it enough to use uGUI buttons only (canvas)? How to do it? Is there any documentation about this?

    I'm also have EasyTouch asset, can I use it with Platformer Pro?

  • 0
    Kukuh Basuki

    Great! Its solved my problem. Thanks

Please sign in to leave a comment.
Powered by Zendesk