Library -Artifacts
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:
-
[!includeopen-hierarchy-window]
-
In the Hierarchy window, select the GameObject that you want to move with the Script Graph.
-
[!includeopen-inspector-window]
-
Select Add Component. The Components menu opens.
-
In the Components menu, do one of the following:
- Go to Input.
- In the Search bar, enter
Player Input
.
-
Select the Player Input component to add it to the GameObject.
-
Add an Input Actions asset to the Player Input component. Do one of the following:
Create a new Input Actions asset
-
Select Create Actions.
-
Choose a location in your project to save the Input Actions asset.
-
Select Save.
Use an existing Input Actions asset
- 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.