Actions

An Action can represent any type of event that should take place as a result of input. Generally, Actions are named for the in-game action they represent, such as: Move Horizontal, Jump, Fire, Reload, Change Weapon, Punch, etc. Actions can also represent system actions such as Menu, Save, Load, Cancel, Back, Forward, etc. How you name and use Actions is entirely up to your game's needs.

Getting Input

Actions are generally how you get input in Rewired. Instead of getting input from a specific button on a specific controller which may change if the user switches controllers, you get input from the Action through the Player class. For example:

private Rewired.Player player;

void Awake() {
    player = Rewired.ReInput.players.GetPlayer(0); // get the player by id
}

void Update() {
    player.GetButtonDown("Fire");
}

This way, you don't have to worry about what type or how many controllers the player is using -- you simply get your input based on the Action.

You can also get input based on the Action id instead. The Action id is displayed in the Rewired Editor under Actions. You can export a list of Action Id constants which adds the convenience of letting you use your IDE's auto-complete to find Actions when coding. Looking up Actions by id is significantly faster than by name and is the recommended method.

Additionally, you have the option of using input events instead of polling for input as shown in the above example. See How To's - Getting Input for more information.

Creating/Editing Actions

You must create and edit Actions in the Rewired Editor. See Rewired Editor - Actions for more information.

Action Categories

Actions can be categorized into different lists through the use of Action Categories.

Action Categories are only for organizational purposes in the Rewired Editor or in lists of Actions for displaying in a UI (a control remapping screen, for example). They have no impact whatsoever on what controls are mapped in a Player and do not affect input in any way.

Rewired’s Purpose and Responsibilities

It is common for Rewired's Action system to be used in an unintended manner as an integral part of or in place of a separate game state management system. This is not what Rewired was designed for and not how it is intended to be used.

  • Rewired’s sole purpose is to read user input.
  • All “Actions” in Rewired are actually “Input Actions” and should not be used for any other purpose than to get information about the user’s intent. They should not be confused with or used as game states or actions.
  • The Action “Jump” does not designate “Player is jumping,” but rather “The user wants to jump.”
  • The game should implement permission and state management systems that evaluate user input and then change states. After that point, what happens is outside the responsibility of the input system.