Importing the New Unity Input System

Remember the weird error we got in Lesson 1? Yeah, we will revert the change we made then to accommodate the new changes we are applying now.

<aside> ☝

Head to the Window tab, and follow these steps: → Go to Package Manager, then search for “Input System” and make sure it is installed

</aside>

image.png

<aside> ☝

Ensure your “Active Input Handling” is set to “Both”: Head now to the “Edit” Tab and follow these steps → Go to Project Settings, then find Player.

→ In “Player”, scroll down to the Other Settings dropdown, then set “Active Input Handling” to both

</aside>

image.png

Editing Movement.cs

Before we tackle the new system package, let's ensure our Movement script is ready to import and initialize the new stuff we are making

<aside> ☝

On Movement.cs, add these lines of code before the “Start()” function

</aside>

  // Input Action Asset to handle our input actions
  [SerializeField] private InputActionAsset inputActions;

  // Input Action for movement
  private InputAction moveAction;

Input Actions Asset:

Now let’s set up the new input system. This is called an Input Action Asset, as it technically works as an asset, like the other game objects we’ve been coding. Lets breakdown what these layers do:

<aside> ☝

On the Edit Tab, go to Project Settings → Input System Package → Create and Assign a Default Project-Wide Action Asset

</aside>

Editing Movement.cs

The beauty of Unity is that implementing controller support is as easy as implementing keyboard input. We will further explore the powerful input management of Unity!