playtest-unity/playtest/Library/PackageCache/com.unity.visualscripting@1.../Documentation~/vs-capture-player-input-add...

2.9 KiB

Add and configure a Player Input component

To use the Input System package with Visual Scripting, add a Player Input component to the same GameObject as the Script Graph and create an Input Actions asset.

You must add the Player Input component and create the Input Actions asset before you create the Script Graph.

[!NOTE] If the Input System package isn't installed in your project, follow the Input System documentation's Installation guide to install the package. Go to Window > Package Manager to check your installed packages.

To add a Player Input component to a GameObject:

  1. [!includeopen-hierarchy-window]

  2. In the Hierarchy window, select the GameObject that you want to move with the Script Graph.

  3. [!includeopen-inspector-window]

  4. Select Add Component. The Components menu opens.

  5. In the Components menu, do one of the following:

    • Go to Input.
    • In the Search bar, enter Player Input.
  6. Select the Player Input component to add it to the GameObject.

  7. Add an Input Actions asset to the Player Input component. Do one of the following:

An image of the Unity Editor's Inspector window, highlighting the Actions section of the Player Input component on a GameObject.

Create a new Input Actions asset

  1. Select Create Actions.

  2. Choose a location in your project to save the Input Actions asset.

  3. Select Save.

Use an existing Input Actions asset

  1. Do one of the following:
    • Click the Actions field's object picker (circle icon) and in the SelectInputActionAsset window, select the asset.
    • Click and drag a file from your Project window and drop it into the Actions field.

Next steps

To configure the available options on a Player Input component, see GameObject components for input in the Input System package documentation.

To configure an Input Actions asset, see Input Action Assets in the Input System package documentation.

To create a simple Script Graph to capture input with Visual Scripting, see Capture input with the Input System package.

Additional resources