static void SetAction( string action, bool down )

book_4_sparkGenerated
code_blocksInput

Description

The SetAction method in the Sandbox.Input class is used to programmatically set the state of a specific input action. This method allows you to simulate the pressing or releasing of an input action by specifying the action's name and its desired state.

Usage

To use the SetAction method, you need to provide two parameters:

  • action (string): The name of the input action you want to modify. This should correspond to an action defined in your input settings.
  • down (bool): A boolean value indicating whether the action should be considered as pressed (true) or released (false).

This method is static, so it can be called directly on the Input class without needing an instance.

Example

// Example of using SetAction to simulate a button press
Sandbox.Input.SetAction("Jump", true);

// Example of using SetAction to simulate a button release
Sandbox.Input.SetAction("Jump", false);