InputAction

Inherits: InputConfig < Resource

Inherited By: InputActionButton, JoystickInputAction2D, KeysInputAction2D

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 an abstraction of a generic input -> action configuration. It declares variables and methods that will be used later to de/serialize and apply this configuration, but leaves the implementation to the implementing sub-classes.

Properties

StringName

category

Methods

void

apply_config()

StringName

get_category()

bool

equals(other_action: InputAction)

bool

contains_input_event(input_event: InputEvent)

Dictionary

get_as_dict()

InputAction

new_from_dict(dict: Dictionary) static


Property Descriptions

StringName category 🔗

InputActions can be put into categories, groups used to choose what o show first and so related actions are grouped together in the UI. This is just a String. InputActions that share the same category tend to be shown together, but there is no hard rule making it mandatory policy.


Method Descriptions

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.


StringName get_category() 🔗

Returns the InputAction’s category. Categories are just groups used to choose what o show first and so related actions are grouped together in the UI.


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.