UnityGame/Library/PackageCache/com.unity.visualscripting/Documentation~/vs-nodes-events-input-system-button.md
2024-10-27 10:53:47 +03:00

3.4 KiB

On Input System Event Button node

Note

The On Input System Event Button node [!includenodes-note-package]

The On Input System Event Button node listens for a specific Input Action from a Player Input component. It doesn't send or read any other data.

Use this node when you want to read user input but don't require any other data from an Input Action.

An image of the Graph window. An On Input System Event Button node displays with its details in the Graph Inspector.

Fuzzy finder category

The On Input System Event Button node is in the Events > Input category in the fuzzy finder.

Inputs

The On Input System Event Button [!includenodes-inputs]

[!includenodes-input-system-ports]

Controls

The On Input System Event Button [!includenodes-controls]

[!includenodes-input-action-change]

You can also set this control from the Graph Inspector.

Additional node settings

The On Input System Event Button [!includenodes-additional-settings]

[!include[nodes-coroutine](./snippets/nodes-coroutine.md)]
Name Type Description

Outputs

The On Input System Event Button [!includenodes-single-output]

[!include[nodes-input-system-output-trigger-port](./snippets/input-system/nodes-input-system-output-trigger-port.md)]
Name Type Description

Example graph usage

In the following example, an On Input System Event Button node counts how many times the user has pressed a button from the Fire Input Action and logs the result to the console.

When a user presses a button associated with the Fire Input Action, Visual Scripting gets the current value of the Count Object variable with a Get Variable node. The Get Variable node sends Count's current value to an Add Inputs node's A port. Then, the Float literal node sends a value of 1 to the Add Inputs node's B port.

The On Input System Event Button node triggers the Set Variable node and assigns the value from the Add Inputs node's Sum port as the New Value of Count. The Set Variable node logs the value of Count to the console with the Debug Log node:

An image of the Graph window, that displays an On Input System Event Button node connected to a Set Variable node. The Set Variable node takes its New Value input from an Add Inputs node, which adds the current value of the Count variable to the value from a Float literal node. The Set Variable node logs the result to the console with a Debug Log node.

[!includevs-nodes-related] On Input System Event Button node: