KeysInputAction2D

Inherits: InputAction < InputConfig < Resource

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Description

This class is specific configuration that maps a 2D input to an action. This is handled by creating 4 different actions, using the action’s name and appending _up, _down, _left or _right to it. So, for instance, a “move” action will have the move_up, move_down, move_left and move_right actions created. In this case, those 4 directions are controlled with 4 different button presses (usually WASD or up, down, left and right keys).

Properties

InputEventKey

up

InputEventKey

down

InputEventKey

left

InputEventKey

right

Methods

Dictionary[StringName, InputEvent]

get_map()

void

apply_config()

bool

equals(other_action: InputAction)

bool

contains_input_event(input_event: InputEvent)

Dictionary

get_as_dict()

InputAction

new_from_dict(dict: Dictionary) static


Enumerations

enum Direction: 🔗

Direction UP = 0

There is currently no description for this enum. Please help us by contributing one!

Direction DOWN = 1

There is currently no description for this enum. Please help us by contributing one!

Direction LEFT = 2

There is currently no description for this enum. Please help us by contributing one!

Direction RIGHT = 3

There is currently no description for this enum. Please help us by contributing one!


Property Descriptions

InputEventKey up 🔗

Key that will trigger the up action (negative Y).


InputEventKey down 🔗

Key that will trigger the down action (positive Y).


InputEventKey left 🔗

Key that will trigger the left action (negative X).


InputEventKey right 🔗

Key that will trigger the right action (positive X).


Method Descriptions

Dictionary[StringName, InputEvent] get_map() 🔗

Returns a Dictionary that maps directions (up, down, left, right) to specific InputEvents that trigger this action to “move” in that direction.


void apply_config() 🔗

If you want to use an InputAction, this is the method to call. This method tells the InputAction to call Godot’s Input API to configure itself there. For concrete actions, this means creating an action on the InputMap and assigning the input to it, for schemes or group of actions this means applying each InputAction individually.


bool equals(other_action: InputAction) 🔗

Checks if the passed InputAction has the same value as the current instance. Returns true if so, false otherwise.


bool contains_input_event(input_event: InputEvent) 🔗

Checks if the InputAction uses the parameter InputEvent in any way. This method is used to know if there are conflicting inputs (inputs used for multiple actions) in the current scheme. This then is used to warn the player about this conflict.


Dictionary get_as_dict() 🔗

Method used for serialization. When saving a control scheme to a file, it is first turned into a Dictionary with the data it needs (category, name, configuration…) so it can be stored as a JSON file. The configuration might include the InputEvent object that triggers the action.


InputAction new_from_dict(dict: Dictionary) static 🔗

Method used for deserialization. When loading a control scheme from a file, new instances of InputAction classes are created with the configuration from the stored JSON file. This method uses the data in those JSON objects to create a new instance of the InputAction.